# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
781603 |
2023-07-13T08:33:28 Z |
Dan4Life |
Fish 2 (JOI22_fish2) |
C++17 |
|
4000 ms |
1996 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, q, a[100010], pr[100010];
using ar = array<int,2>;
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; cin >> q;
while(q--){
int t, l, r; cin >> t >> l >> r;
if(t==1) a[l]=r;
else{
stack<ar> S = stack<ar>(); int sum = 0, ind;
for(int i = l; i <= r; i++)pr[i]=0;
for(int i = l; i <= r; i++){
sum = 0, ind = -1;
while(!S.empty() and a[S.top()[1]] < a[i])
sum+=S.top()[0]+a[S.top()[1]], S.pop();
if(sum<a[i]) ind=S.empty()?l:S.top()[1]+1;
if(ind!=-1) pr[ind]++, pr[i]--;
S.push({sum,i});
}
S = stack<ar>();
for(int i = r; i >= l; i--){
sum = 0, ind = -1;
while(!S.empty() and a[S.top()[1]] < a[i])
sum+=S.top()[0]+a[S.top()[1]], S.pop();
if(sum<a[i]) ind=S.empty()?r+1:S.top()[1];
if(ind!=-1) pr[i+1]++, pr[ind]--;
S.push({sum,i});
}
int ans = 0, xd=0;
for(int i = l; i <= r; i++)
xd+=pr[i], ans+=!xd;
cout << ans << "\n";
}
}
}
# |
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 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
3 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
5 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
10 ms |
1876 KB |
Output is correct |
3 |
Correct |
8 ms |
1784 KB |
Output is correct |
4 |
Correct |
9 ms |
1876 KB |
Output is correct |
5 |
Correct |
8 ms |
1876 KB |
Output is correct |
6 |
Correct |
12 ms |
1876 KB |
Output is correct |
7 |
Correct |
8 ms |
1888 KB |
Output is correct |
8 |
Correct |
12 ms |
1824 KB |
Output is correct |
9 |
Correct |
9 ms |
1876 KB |
Output is correct |
10 |
Correct |
10 ms |
1792 KB |
Output is correct |
11 |
Correct |
8 ms |
1884 KB |
Output is correct |
12 |
Correct |
9 ms |
1876 KB |
Output is correct |
13 |
Correct |
9 ms |
1876 KB |
Output is correct |
14 |
Correct |
9 ms |
1876 KB |
Output is correct |
15 |
Correct |
10 ms |
1876 KB |
Output is correct |
# |
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 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
3 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
5 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
10 ms |
1876 KB |
Output is correct |
23 |
Correct |
8 ms |
1784 KB |
Output is correct |
24 |
Correct |
9 ms |
1876 KB |
Output is correct |
25 |
Correct |
8 ms |
1876 KB |
Output is correct |
26 |
Correct |
12 ms |
1876 KB |
Output is correct |
27 |
Correct |
8 ms |
1888 KB |
Output is correct |
28 |
Correct |
12 ms |
1824 KB |
Output is correct |
29 |
Correct |
9 ms |
1876 KB |
Output is correct |
30 |
Correct |
10 ms |
1792 KB |
Output is correct |
31 |
Correct |
8 ms |
1884 KB |
Output is correct |
32 |
Correct |
9 ms |
1876 KB |
Output is correct |
33 |
Correct |
9 ms |
1876 KB |
Output is correct |
34 |
Correct |
9 ms |
1876 KB |
Output is correct |
35 |
Correct |
10 ms |
1876 KB |
Output is correct |
36 |
Correct |
439 ms |
1916 KB |
Output is correct |
37 |
Correct |
674 ms |
1980 KB |
Output is correct |
38 |
Correct |
792 ms |
1944 KB |
Output is correct |
39 |
Correct |
176 ms |
1896 KB |
Output is correct |
40 |
Correct |
885 ms |
1876 KB |
Output is correct |
41 |
Correct |
833 ms |
1940 KB |
Output is correct |
42 |
Correct |
1066 ms |
1876 KB |
Output is correct |
43 |
Correct |
945 ms |
1872 KB |
Output is correct |
44 |
Correct |
1119 ms |
1868 KB |
Output is correct |
45 |
Correct |
481 ms |
1876 KB |
Output is correct |
46 |
Correct |
664 ms |
1980 KB |
Output is correct |
47 |
Correct |
998 ms |
1992 KB |
Output is correct |
48 |
Correct |
336 ms |
1884 KB |
Output is correct |
49 |
Correct |
1137 ms |
1888 KB |
Output is correct |
50 |
Correct |
503 ms |
1948 KB |
Output is correct |
51 |
Correct |
2339 ms |
1952 KB |
Output is correct |
52 |
Correct |
2452 ms |
1952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
10 ms |
1876 KB |
Output is correct |
3 |
Correct |
8 ms |
1784 KB |
Output is correct |
4 |
Correct |
9 ms |
1876 KB |
Output is correct |
5 |
Correct |
8 ms |
1876 KB |
Output is correct |
6 |
Correct |
12 ms |
1876 KB |
Output is correct |
7 |
Correct |
8 ms |
1888 KB |
Output is correct |
8 |
Correct |
12 ms |
1824 KB |
Output is correct |
9 |
Correct |
9 ms |
1876 KB |
Output is correct |
10 |
Correct |
10 ms |
1792 KB |
Output is correct |
11 |
Correct |
8 ms |
1884 KB |
Output is correct |
12 |
Correct |
9 ms |
1876 KB |
Output is correct |
13 |
Correct |
9 ms |
1876 KB |
Output is correct |
14 |
Correct |
9 ms |
1876 KB |
Output is correct |
15 |
Correct |
10 ms |
1876 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Execution timed out |
4043 ms |
1872 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
10 ms |
1876 KB |
Output is correct |
3 |
Correct |
8 ms |
1784 KB |
Output is correct |
4 |
Correct |
9 ms |
1876 KB |
Output is correct |
5 |
Correct |
8 ms |
1876 KB |
Output is correct |
6 |
Correct |
12 ms |
1876 KB |
Output is correct |
7 |
Correct |
8 ms |
1888 KB |
Output is correct |
8 |
Correct |
12 ms |
1824 KB |
Output is correct |
9 |
Correct |
9 ms |
1876 KB |
Output is correct |
10 |
Correct |
10 ms |
1792 KB |
Output is correct |
11 |
Correct |
8 ms |
1884 KB |
Output is correct |
12 |
Correct |
9 ms |
1876 KB |
Output is correct |
13 |
Correct |
9 ms |
1876 KB |
Output is correct |
14 |
Correct |
9 ms |
1876 KB |
Output is correct |
15 |
Correct |
10 ms |
1876 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Execution timed out |
4054 ms |
1996 KB |
Time limit exceeded |
18 |
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 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
3 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
5 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
10 ms |
1876 KB |
Output is correct |
23 |
Correct |
8 ms |
1784 KB |
Output is correct |
24 |
Correct |
9 ms |
1876 KB |
Output is correct |
25 |
Correct |
8 ms |
1876 KB |
Output is correct |
26 |
Correct |
12 ms |
1876 KB |
Output is correct |
27 |
Correct |
8 ms |
1888 KB |
Output is correct |
28 |
Correct |
12 ms |
1824 KB |
Output is correct |
29 |
Correct |
9 ms |
1876 KB |
Output is correct |
30 |
Correct |
10 ms |
1792 KB |
Output is correct |
31 |
Correct |
8 ms |
1884 KB |
Output is correct |
32 |
Correct |
9 ms |
1876 KB |
Output is correct |
33 |
Correct |
9 ms |
1876 KB |
Output is correct |
34 |
Correct |
9 ms |
1876 KB |
Output is correct |
35 |
Correct |
10 ms |
1876 KB |
Output is correct |
36 |
Correct |
439 ms |
1916 KB |
Output is correct |
37 |
Correct |
674 ms |
1980 KB |
Output is correct |
38 |
Correct |
792 ms |
1944 KB |
Output is correct |
39 |
Correct |
176 ms |
1896 KB |
Output is correct |
40 |
Correct |
885 ms |
1876 KB |
Output is correct |
41 |
Correct |
833 ms |
1940 KB |
Output is correct |
42 |
Correct |
1066 ms |
1876 KB |
Output is correct |
43 |
Correct |
945 ms |
1872 KB |
Output is correct |
44 |
Correct |
1119 ms |
1868 KB |
Output is correct |
45 |
Correct |
481 ms |
1876 KB |
Output is correct |
46 |
Correct |
664 ms |
1980 KB |
Output is correct |
47 |
Correct |
998 ms |
1992 KB |
Output is correct |
48 |
Correct |
336 ms |
1884 KB |
Output is correct |
49 |
Correct |
1137 ms |
1888 KB |
Output is correct |
50 |
Correct |
503 ms |
1948 KB |
Output is correct |
51 |
Correct |
2339 ms |
1952 KB |
Output is correct |
52 |
Correct |
2452 ms |
1952 KB |
Output is correct |
53 |
Correct |
1 ms |
212 KB |
Output is correct |
54 |
Execution timed out |
4043 ms |
1872 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |