# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
886404 |
2023-12-12T03:47:52 Z |
dong_liu |
Fish 2 (JOI22_fish2) |
C++17 |
|
4000 ms |
4024 KB |
#include <bits/stdc++.h>
using namespace std;
#define ar aay
#define sz(v) int(std::size(v))
using i64 = long long;
using pii = pair<int, int>;
const int N = 1e5+5;
const i64 INF = 1e18;
int n, q;
i64 a[N], sm[N], c[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
cin >> q;
while (q--) {
int t;
cin >> t;
if (t == 1) {
int i, x;
cin >> i >> x;
a[i] = x;
} else {
int s, e;
cin >> s >> e;
for (int i = 1; i <= n; i++) sm[i] = sm[i - 1] + a[i], c[i] = 0;
vector<pair<int, i64>> v;
v.push_back({s - 1, INF});
for (int i = s; i <= e + 1; i++) {
while (!v.empty() && v.back().second <= (i == e + 1 ? INF : a[i])) {
int l = v.back().first, r = i;
if (l == s - 1 && r == e + 1) break;
v.pop_back();
if (sm[r - 1] - sm[l] < min(l == s - 1 ? INF : a[l], r == e + 1 ? INF : a[r])) c[l + 1]++, c[r]--;
}
int l = v.back().first, r = i;
if (!(l == s - 1 && r == e + 1) && sm[r - 1] - sm[l] < min(l == s - 1 ? INF : a[l], r == e + 1 ? INF : a[r]))
c[l + 1]++, c[r]--;
v.push_back(make_pair(i, a[i]));
}
for (int i = 1; i <= n; i++) c[i] += c[i - 1];
int k = 0;
for (int i = s; i <= e; i++) if (!c[i]) k++;
cout << k << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
2 ms |
2396 KB |
Output is correct |
9 |
Correct |
3 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
3 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
3 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2520 KB |
Output is correct |
15 |
Correct |
2 ms |
2396 KB |
Output is correct |
16 |
Correct |
3 ms |
2396 KB |
Output is correct |
17 |
Correct |
2 ms |
2396 KB |
Output is correct |
18 |
Correct |
3 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
4 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
9 ms |
3288 KB |
Output is correct |
3 |
Correct |
7 ms |
2908 KB |
Output is correct |
4 |
Correct |
10 ms |
3392 KB |
Output is correct |
5 |
Correct |
8 ms |
2908 KB |
Output is correct |
6 |
Correct |
10 ms |
3676 KB |
Output is correct |
7 |
Correct |
9 ms |
3016 KB |
Output is correct |
8 |
Correct |
14 ms |
3672 KB |
Output is correct |
9 |
Correct |
7 ms |
2908 KB |
Output is correct |
10 |
Correct |
9 ms |
3164 KB |
Output is correct |
11 |
Correct |
7 ms |
2908 KB |
Output is correct |
12 |
Correct |
7 ms |
3024 KB |
Output is correct |
13 |
Correct |
7 ms |
2884 KB |
Output is correct |
14 |
Correct |
8 ms |
3164 KB |
Output is correct |
15 |
Correct |
9 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
2 ms |
2396 KB |
Output is correct |
9 |
Correct |
3 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
3 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
3 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2520 KB |
Output is correct |
15 |
Correct |
2 ms |
2396 KB |
Output is correct |
16 |
Correct |
3 ms |
2396 KB |
Output is correct |
17 |
Correct |
2 ms |
2396 KB |
Output is correct |
18 |
Correct |
3 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
4 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
9 ms |
3288 KB |
Output is correct |
23 |
Correct |
7 ms |
2908 KB |
Output is correct |
24 |
Correct |
10 ms |
3392 KB |
Output is correct |
25 |
Correct |
8 ms |
2908 KB |
Output is correct |
26 |
Correct |
10 ms |
3676 KB |
Output is correct |
27 |
Correct |
9 ms |
3016 KB |
Output is correct |
28 |
Correct |
14 ms |
3672 KB |
Output is correct |
29 |
Correct |
7 ms |
2908 KB |
Output is correct |
30 |
Correct |
9 ms |
3164 KB |
Output is correct |
31 |
Correct |
7 ms |
2908 KB |
Output is correct |
32 |
Correct |
7 ms |
3024 KB |
Output is correct |
33 |
Correct |
7 ms |
2884 KB |
Output is correct |
34 |
Correct |
8 ms |
3164 KB |
Output is correct |
35 |
Correct |
9 ms |
3164 KB |
Output is correct |
36 |
Correct |
478 ms |
3376 KB |
Output is correct |
37 |
Correct |
707 ms |
3136 KB |
Output is correct |
38 |
Correct |
871 ms |
3156 KB |
Output is correct |
39 |
Correct |
201 ms |
3380 KB |
Output is correct |
40 |
Correct |
912 ms |
3152 KB |
Output is correct |
41 |
Correct |
759 ms |
3776 KB |
Output is correct |
42 |
Correct |
969 ms |
4024 KB |
Output is correct |
43 |
Correct |
741 ms |
3260 KB |
Output is correct |
44 |
Correct |
912 ms |
3008 KB |
Output is correct |
45 |
Correct |
477 ms |
3368 KB |
Output is correct |
46 |
Correct |
656 ms |
3408 KB |
Output is correct |
47 |
Correct |
924 ms |
3332 KB |
Output is correct |
48 |
Correct |
303 ms |
3056 KB |
Output is correct |
49 |
Correct |
985 ms |
3052 KB |
Output is correct |
50 |
Correct |
518 ms |
3416 KB |
Output is correct |
51 |
Correct |
1595 ms |
3652 KB |
Output is correct |
52 |
Correct |
1870 ms |
3416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
9 ms |
3288 KB |
Output is correct |
3 |
Correct |
7 ms |
2908 KB |
Output is correct |
4 |
Correct |
10 ms |
3392 KB |
Output is correct |
5 |
Correct |
8 ms |
2908 KB |
Output is correct |
6 |
Correct |
10 ms |
3676 KB |
Output is correct |
7 |
Correct |
9 ms |
3016 KB |
Output is correct |
8 |
Correct |
14 ms |
3672 KB |
Output is correct |
9 |
Correct |
7 ms |
2908 KB |
Output is correct |
10 |
Correct |
9 ms |
3164 KB |
Output is correct |
11 |
Correct |
7 ms |
2908 KB |
Output is correct |
12 |
Correct |
7 ms |
3024 KB |
Output is correct |
13 |
Correct |
7 ms |
2884 KB |
Output is correct |
14 |
Correct |
8 ms |
3164 KB |
Output is correct |
15 |
Correct |
9 ms |
3164 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Execution timed out |
4070 ms |
3288 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
9 ms |
3288 KB |
Output is correct |
3 |
Correct |
7 ms |
2908 KB |
Output is correct |
4 |
Correct |
10 ms |
3392 KB |
Output is correct |
5 |
Correct |
8 ms |
2908 KB |
Output is correct |
6 |
Correct |
10 ms |
3676 KB |
Output is correct |
7 |
Correct |
9 ms |
3016 KB |
Output is correct |
8 |
Correct |
14 ms |
3672 KB |
Output is correct |
9 |
Correct |
7 ms |
2908 KB |
Output is correct |
10 |
Correct |
9 ms |
3164 KB |
Output is correct |
11 |
Correct |
7 ms |
2908 KB |
Output is correct |
12 |
Correct |
7 ms |
3024 KB |
Output is correct |
13 |
Correct |
7 ms |
2884 KB |
Output is correct |
14 |
Correct |
8 ms |
3164 KB |
Output is correct |
15 |
Correct |
9 ms |
3164 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Execution timed out |
4054 ms |
3800 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
2 ms |
2396 KB |
Output is correct |
9 |
Correct |
3 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
3 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
3 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2520 KB |
Output is correct |
15 |
Correct |
2 ms |
2396 KB |
Output is correct |
16 |
Correct |
3 ms |
2396 KB |
Output is correct |
17 |
Correct |
2 ms |
2396 KB |
Output is correct |
18 |
Correct |
3 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
4 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
9 ms |
3288 KB |
Output is correct |
23 |
Correct |
7 ms |
2908 KB |
Output is correct |
24 |
Correct |
10 ms |
3392 KB |
Output is correct |
25 |
Correct |
8 ms |
2908 KB |
Output is correct |
26 |
Correct |
10 ms |
3676 KB |
Output is correct |
27 |
Correct |
9 ms |
3016 KB |
Output is correct |
28 |
Correct |
14 ms |
3672 KB |
Output is correct |
29 |
Correct |
7 ms |
2908 KB |
Output is correct |
30 |
Correct |
9 ms |
3164 KB |
Output is correct |
31 |
Correct |
7 ms |
2908 KB |
Output is correct |
32 |
Correct |
7 ms |
3024 KB |
Output is correct |
33 |
Correct |
7 ms |
2884 KB |
Output is correct |
34 |
Correct |
8 ms |
3164 KB |
Output is correct |
35 |
Correct |
9 ms |
3164 KB |
Output is correct |
36 |
Correct |
478 ms |
3376 KB |
Output is correct |
37 |
Correct |
707 ms |
3136 KB |
Output is correct |
38 |
Correct |
871 ms |
3156 KB |
Output is correct |
39 |
Correct |
201 ms |
3380 KB |
Output is correct |
40 |
Correct |
912 ms |
3152 KB |
Output is correct |
41 |
Correct |
759 ms |
3776 KB |
Output is correct |
42 |
Correct |
969 ms |
4024 KB |
Output is correct |
43 |
Correct |
741 ms |
3260 KB |
Output is correct |
44 |
Correct |
912 ms |
3008 KB |
Output is correct |
45 |
Correct |
477 ms |
3368 KB |
Output is correct |
46 |
Correct |
656 ms |
3408 KB |
Output is correct |
47 |
Correct |
924 ms |
3332 KB |
Output is correct |
48 |
Correct |
303 ms |
3056 KB |
Output is correct |
49 |
Correct |
985 ms |
3052 KB |
Output is correct |
50 |
Correct |
518 ms |
3416 KB |
Output is correct |
51 |
Correct |
1595 ms |
3652 KB |
Output is correct |
52 |
Correct |
1870 ms |
3416 KB |
Output is correct |
53 |
Correct |
1 ms |
2396 KB |
Output is correct |
54 |
Execution timed out |
4070 ms |
3288 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |