//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 100015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int n,q,arr[N];
signed main(){
fast
cin>>n;
for (int i=1;i<=n;i++)
cin>>arr[i];
cin>>q;
for (int i=1;i<=q;i++){
int type,l,r; cin>>type>>l>>r;
if (type==1){
arr[l]=r;
}
else {
int ans=0,nl,nr,now=0;
for (int j=l;j<=r;j++){
nl=j-1; nr=j+1; now=arr[j];
while (nl>=l||nr<=r){
if (nl>=l&&now>=arr[nl]){
now+=arr[nl];
nl--;
}
else if (nr<=r&&now>=arr[nr]){
now+=arr[nr];
nr++;
}
else break;
}
if (nl<l&&nr>r) ans++;
}
cout<<ans<<'\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
6 ms |
340 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
9 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
9 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
21 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
394 ms |
1668 KB |
Output is correct |
3 |
Correct |
48 ms |
1424 KB |
Output is correct |
4 |
Correct |
364 ms |
1668 KB |
Output is correct |
5 |
Correct |
47 ms |
1316 KB |
Output is correct |
6 |
Correct |
3856 ms |
2060 KB |
Output is correct |
7 |
Correct |
712 ms |
1356 KB |
Output is correct |
8 |
Correct |
3751 ms |
2060 KB |
Output is correct |
9 |
Correct |
430 ms |
1300 KB |
Output is correct |
10 |
Correct |
446 ms |
1764 KB |
Output is correct |
11 |
Correct |
24 ms |
1364 KB |
Output is correct |
12 |
Correct |
940 ms |
1340 KB |
Output is correct |
13 |
Correct |
1045 ms |
1344 KB |
Output is correct |
14 |
Correct |
2348 ms |
1740 KB |
Output is correct |
15 |
Correct |
2082 ms |
1692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
6 ms |
340 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
9 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
9 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
21 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
394 ms |
1668 KB |
Output is correct |
23 |
Correct |
48 ms |
1424 KB |
Output is correct |
24 |
Correct |
364 ms |
1668 KB |
Output is correct |
25 |
Correct |
47 ms |
1316 KB |
Output is correct |
26 |
Correct |
3856 ms |
2060 KB |
Output is correct |
27 |
Correct |
712 ms |
1356 KB |
Output is correct |
28 |
Correct |
3751 ms |
2060 KB |
Output is correct |
29 |
Correct |
430 ms |
1300 KB |
Output is correct |
30 |
Correct |
446 ms |
1764 KB |
Output is correct |
31 |
Correct |
24 ms |
1364 KB |
Output is correct |
32 |
Correct |
940 ms |
1340 KB |
Output is correct |
33 |
Correct |
1045 ms |
1344 KB |
Output is correct |
34 |
Correct |
2348 ms |
1740 KB |
Output is correct |
35 |
Correct |
2082 ms |
1692 KB |
Output is correct |
36 |
Execution timed out |
4051 ms |
1620 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
394 ms |
1668 KB |
Output is correct |
3 |
Correct |
48 ms |
1424 KB |
Output is correct |
4 |
Correct |
364 ms |
1668 KB |
Output is correct |
5 |
Correct |
47 ms |
1316 KB |
Output is correct |
6 |
Correct |
3856 ms |
2060 KB |
Output is correct |
7 |
Correct |
712 ms |
1356 KB |
Output is correct |
8 |
Correct |
3751 ms |
2060 KB |
Output is correct |
9 |
Correct |
430 ms |
1300 KB |
Output is correct |
10 |
Correct |
446 ms |
1764 KB |
Output is correct |
11 |
Correct |
24 ms |
1364 KB |
Output is correct |
12 |
Correct |
940 ms |
1340 KB |
Output is correct |
13 |
Correct |
1045 ms |
1344 KB |
Output is correct |
14 |
Correct |
2348 ms |
1740 KB |
Output is correct |
15 |
Correct |
2082 ms |
1692 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Execution timed out |
4078 ms |
1496 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
394 ms |
1668 KB |
Output is correct |
3 |
Correct |
48 ms |
1424 KB |
Output is correct |
4 |
Correct |
364 ms |
1668 KB |
Output is correct |
5 |
Correct |
47 ms |
1316 KB |
Output is correct |
6 |
Correct |
3856 ms |
2060 KB |
Output is correct |
7 |
Correct |
712 ms |
1356 KB |
Output is correct |
8 |
Correct |
3751 ms |
2060 KB |
Output is correct |
9 |
Correct |
430 ms |
1300 KB |
Output is correct |
10 |
Correct |
446 ms |
1764 KB |
Output is correct |
11 |
Correct |
24 ms |
1364 KB |
Output is correct |
12 |
Correct |
940 ms |
1340 KB |
Output is correct |
13 |
Correct |
1045 ms |
1344 KB |
Output is correct |
14 |
Correct |
2348 ms |
1740 KB |
Output is correct |
15 |
Correct |
2082 ms |
1692 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Execution timed out |
4073 ms |
1808 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
6 ms |
340 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
9 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
9 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
340 KB |
Output is correct |
20 |
Correct |
21 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
394 ms |
1668 KB |
Output is correct |
23 |
Correct |
48 ms |
1424 KB |
Output is correct |
24 |
Correct |
364 ms |
1668 KB |
Output is correct |
25 |
Correct |
47 ms |
1316 KB |
Output is correct |
26 |
Correct |
3856 ms |
2060 KB |
Output is correct |
27 |
Correct |
712 ms |
1356 KB |
Output is correct |
28 |
Correct |
3751 ms |
2060 KB |
Output is correct |
29 |
Correct |
430 ms |
1300 KB |
Output is correct |
30 |
Correct |
446 ms |
1764 KB |
Output is correct |
31 |
Correct |
24 ms |
1364 KB |
Output is correct |
32 |
Correct |
940 ms |
1340 KB |
Output is correct |
33 |
Correct |
1045 ms |
1344 KB |
Output is correct |
34 |
Correct |
2348 ms |
1740 KB |
Output is correct |
35 |
Correct |
2082 ms |
1692 KB |
Output is correct |
36 |
Execution timed out |
4051 ms |
1620 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |