Skip to content

Commit ede85a4

Browse files
authored
Create HILLS.cpp
1 parent af26b0f commit ede85a4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Codeshef/HILLS.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main(){
5+
int T;
6+
cin>>T;
7+
while(T--){
8+
int n,u,d,para=1;
9+
cin>>n>>u>>d;
10+
int arr[n],total=1;
11+
for(int i=0;i<n;i++){
12+
cin>>arr[i];
13+
}
14+
for(int i=1;i<n;i++){
15+
if(arr[i]>=arr[i-1]){
16+
if((arr[i]-arr[i-1])<=u){
17+
total++;
18+
}
19+
else{
20+
break;
21+
}
22+
}
23+
else{
24+
if((arr[i-1]-arr[i])>d){
25+
para--;
26+
if(para<0)break;
27+
}
28+
total++;
29+
}
30+
31+
}
32+
cout<<total<<endl;
33+
}
34+
return 0;
35+
}

0 commit comments

Comments
 (0)