My issue
I worked up a solution and it ran for the test case(provided in the example but it gave a wrong answer when I submitted it.
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int T;
cin>>T;
while(T--){
int N,U,D;
cin>>N>>U>>D;
int P=1;
int H[N];
int nh=1;
/*cout<<N<<' '<<U<<' '<<D<<endl;*/
for(int i=0;i<N;i++){
int h;
cin>>h;
H[i]=h;
}
for(int i=0;i<(N-1);i++){
if((H[(i+1)])==(H[i])){
nh++;
}
else if((H[(i+1)]>H[i])&&(H[(i+1)]<=(H[i]+U))){
nh++;
}
else if(H[i]>H[(i+1)]){
if(H[i]<=(H[(i+1)]+D)){
nh++;
}
else if(P==1){
P--;
nh++;
}
}
else {
break;
}
}
cout<<nh<<"\n";
}
}
Problem Link: Jumping in the hills Practice Coding Problem - CodeChef