#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;
// cout<<gde<<" "<<duz<<" "<<vp<<" "<<tip<<" "<<kraj<<endl;
if((duz+niz[gde])*tip>vp*tip)
return 1+duzina(gde+1,0,duz+niz[gde],tip*-1,kraj);
if(tip==1)
return duzina(gde+1,duz+niz[gde],vp,tip,kraj);
else
return duzina(gde+1,0,vp+niz[gde],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;
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 |
1 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 |
1 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 |
1 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 |
188 ms |
1916 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
169 ms |
2252 KB |
Output isn't correct |
4 |
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 |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |