-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaug7.cpp
More file actions
40 lines (39 loc) · 685 Bytes
/
aug7.cpp
File metadata and controls
40 lines (39 loc) · 685 Bytes
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
#include<iostream>
#include<algorithm>
#define ll long long int
using namespace std;
int main()
{
ll a[100000],n,q,t,i,l,r,x,pre,pre_h;
cin>>n>>q;
for(i=1;i<=n;i++)
cin>>a[i];
while(q--)
{
cin>>t;
if(t==1)
{
cin>>l>>r;
pre=l,pre_h=a[l];
for(i=l+1;i<=n&&r>0;i++)
{
if((a[i]-pre_h)>0&&(i-pre)<=100)
{
pre=i;
pre_h=a[i];
r--;
}
else if(a[i]<=pre_h)
continue;
}
cout<<pre<<endl;
}
if(t==2)
{
cin>>l>>r>>x;
for(i=l;i<=r;i++)
a[i]=a[i]+x;
}
}
return 0;
}