-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockadventure.java
More file actions
40 lines (37 loc) · 1.1 KB
/
blockadventure.java
File metadata and controls
40 lines (37 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.awt.*;
import java.io.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.util.Map;
public class blockadventure {
public static void main(String[] args){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
int m = sc.nextInt();
int k = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = sc.nextInt();
boolean x = true;
int r;
for (int i = 0; i < n - 1; i++) {
r = Integer.max(0, a[i + 1] - k);
m += a[i] - r;
if (m < 0) {
x = false;
break;
}
}
if (x) System.out.println("YES");
else System.out.println("NO");
}
}
}