-
Notifications
You must be signed in to change notification settings - Fork 2
/
HILLS.cpp
62 lines (60 loc) · 1.23 KB
/
HILLS.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<bits/stdc++.h>
using namespace std;
int main()
{
long int t;
cin>>t;
while(t--)
{
long int n,u,d;
cin>>n>>u>>d;
vector<long int>arr(n);
for(long int i=0;i<n;i++)
{
cin>>arr[i];
}
long int ans =1;
bool p=1;
for(long int i=0;i<n-1;i++)
{
long int x=arr[i];
long int y=arr[i+1];
if(y>x)
{
if(y-x<=u)
{
ans=i+2;
}
else
{
//ans=i+1;
i=n;
break;
}
}
else
{
if(x-y<=d)
{
ans=i+2;
}
else
{
if(p)
{
// c=h;
p=0;
ans=i+2;
}
else
{
// ans=i+1;
i=n;
break;
}
}
}
}
cout<<ans<<endl;
}
}