-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCF1200B.cpp
48 lines (48 loc) · 870 Bytes
/
CF1200B.cpp
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
41
42
43
44
45
46
47
48
#include <iostream>
#include <cstdio>
using namespace std;
int n,m,k;
int h[110];
int main()
{
#ifdef CODEBLOCKS
freopen("in.txt","r",stdin);
#endif // CODEBLOCKS
int t;
cin>>t;
for(int ti=0;ti<t;ti++)
{
cin>>n>>m>>k;
for(int i=0;i<n;i++)
{
cin>>h[i];
}
bool flag = true;
for(int i=0;i<n-1;i++)
{
int to_next = max(0, h[i+1]-k);
if(h[i]>to_next)
{
m+=h[i]-to_next;
}
else
{
m-=to_next - h[i];
}
if(m<0)
{
flag = false;
break;
}
}
if(flag)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
return 0;
}