#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll N,Q,niz[250005];
/*
1 veci
-1 manji
*/
ll duzina(ll gde,ll duz,ll vp,ll tip,ll kraj){
if(gde>kraj)
return 0;
duz+=niz[gde];
// cout<<gde<<" "<<duz<<" "<<vp<<" "<<tip<<" "<<kraj<<endl;
if(duz*tip>vp*tip)
return 1+duzina(gde+1,0,duz,tip*-1,kraj);
if(tip==1)
return duzina(gde+1,duz,vp,tip,kraj);
else
return duzina(gde+1,0,vp+duz,tip,kraj);
}
int main(){
cin>>N;
for(int i=1;i<=N;i++)
cin>>niz[i];
cin>>Q;
while(Q--){
ll a,b,L,R;
cin>>a>>b>>L>>R;
//a++;
L++;
niz[a]=b;
cout<<max(duzina(L,0,1e18,-1,R),duzina(L,0,-1e18,1,R))<<endl;
}
return 0;
}
/*
4
6 2 3 2
1
3 2 1 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
207 ms |
2064 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
203 ms |
2404 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |