#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n;
cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
int q;
cin>>q;
while(q--){
int t;
cin>>t;
if(t==1){
int i;cin>>i;i--;
int x;cin>>x;
v[i]=x;
}else{
int ans=0;
int l,r;cin>>l>>r,l--,r--;
for(int i=l;i<=r;i++){
int s=v[i];
int a=i-1;
int b=i+1;
int c=1;
while(true){
bool ok=true;
if(a>=l&&s>=v[a]){
ok=false;
s+=v[a];a--;
c++;
}
if(b<=r&&s>=v[b]){
s+=v[b];
b++;
c++;
ok=0;
}
if(ok) break;
}
ans+=c==(r-l+1);
}
cout<<ans<<endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
348 KB |
Output is correct |
11 |
Correct |
9 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
3 ms |
348 KB |
Output is correct |
16 |
Correct |
8 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
3 ms |
348 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
25 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
417 ms |
1788 KB |
Output is correct |
3 |
Correct |
51 ms |
1368 KB |
Output is correct |
4 |
Correct |
412 ms |
1628 KB |
Output is correct |
5 |
Correct |
68 ms |
1624 KB |
Output is correct |
6 |
Execution timed out |
4077 ms |
2108 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
348 KB |
Output is correct |
11 |
Correct |
9 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
3 ms |
348 KB |
Output is correct |
16 |
Correct |
8 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
3 ms |
348 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
25 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
417 ms |
1788 KB |
Output is correct |
23 |
Correct |
51 ms |
1368 KB |
Output is correct |
24 |
Correct |
412 ms |
1628 KB |
Output is correct |
25 |
Correct |
68 ms |
1624 KB |
Output is correct |
26 |
Execution timed out |
4077 ms |
2108 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
417 ms |
1788 KB |
Output is correct |
3 |
Correct |
51 ms |
1368 KB |
Output is correct |
4 |
Correct |
412 ms |
1628 KB |
Output is correct |
5 |
Correct |
68 ms |
1624 KB |
Output is correct |
6 |
Execution timed out |
4077 ms |
2108 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
417 ms |
1788 KB |
Output is correct |
3 |
Correct |
51 ms |
1368 KB |
Output is correct |
4 |
Correct |
412 ms |
1628 KB |
Output is correct |
5 |
Correct |
68 ms |
1624 KB |
Output is correct |
6 |
Execution timed out |
4077 ms |
2108 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
348 KB |
Output is correct |
11 |
Correct |
9 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
3 ms |
348 KB |
Output is correct |
16 |
Correct |
8 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
3 ms |
348 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
25 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
417 ms |
1788 KB |
Output is correct |
23 |
Correct |
51 ms |
1368 KB |
Output is correct |
24 |
Correct |
412 ms |
1628 KB |
Output is correct |
25 |
Correct |
68 ms |
1624 KB |
Output is correct |
26 |
Execution timed out |
4077 ms |
2108 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |