-
Notifications
You must be signed in to change notification settings - Fork 93
/
HILLS
47 lines (42 loc) · 737 Bytes
/
HILLS
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
// https://www.codechef.com/problems/HILLS
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes
int t;
cin>>t;
while(t--)
{
int n,u,d;
cin>>n>>u>>d;
vector<int> v(n);
for(int i=0;i<n;i++)
cin>>v[i];
int para = 1;
int cnt = 1;
for(int i=0;i<n-1;i++)
{
if(v[i]>=v[i+1])
{
if(v[i]-v[i+1]<=d)
cnt++;
else if(para>0)
{
cnt++;
para--;
}
else
break;
}
if(v[i]<v[i+1])
{
if(v[i+1]-v[i]<=u)
cnt++;
else
break;
}
}
cout<<cnt<<endl;
}
return 0;
}