https://www.codechef.com/problems/REDALERT

#include

using namespace std;

#define ll long long

int main() {

long WL=0;long i=0;

ll T,N,D,H;

cin>>T;

while(T–)

{

cin>>N>>D>>H;

long A[N];

for(long i=0;i<N;i++)

{

cin>>A[i];

}

```
for(long j=0;j<N;j++)
{
if(A[j]>0)
WL+=A[j];
else {
if(A[j]==0)
{
if(WL>D)
WL-=D;
else
WL=0;
}
}
if(WL>H)
{
i=1;
break;
}
```

}

```
if(i==0)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
```

}

return 0;

}