-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfdgdf.cpp
More file actions
59 lines (53 loc) · 1.07 KB
/
fdgdf.cpp
File metadata and controls
59 lines (53 loc) · 1.07 KB
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
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,q,temp;
int ans=0;
//cout<<ans;
cin>>n>>q;
int h[size1],a[size1];
for(int i=0;i<n;i++)
cin>>h[i];
int max1=h[0];
int caount1=1;
for(int i=0;i<n;i++)
{ if(h[i]>max1)
{
count1++;
a[i]=count1;
max1=h[i];
}
else
{
a[i]=count1;
}
}
//for(int i=0;i<n;i++)
//cout<<" "<<a[i];
int l,r;
while(q--)
{
cin>>l>>r;
l=(l+ans)%n;
r=(r+ans)%n;
//cout<<"new l:"<<l<<"new r:"<<r<<"\n";
if(l>r)
{
temp=l;
l=r;
r=temp;
}
if(l!=0)
{
if(a[l]==a[l-1])
ans=a[r]-a[l];
else
ans=a[r]-a[l]+1;
}
if(l==0)
ans=a[r]-a[l]+1;
cout<<ans<<"\n";
}
}