# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
937800 | 2024-03-04T13:23:29 Z | nguyentunglam | Fish 2 (JOI22_fish2) | C++17 | 4000 ms | 3572 KB |
#include<bits/stdc++.h> #define all(v) v.begin(), v.end() #define endl "\n" #define int long long using namespace std; const int N = 1e5 + 10; int a[N]; int32_t main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } if (fopen(task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int n; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; int q; cin >> q; a[0] = a[n + 1] = 1e18; while (q--) { int t, x, y; cin >> t >> x >> y; if (t == 1) a[x] = y; else { int ans = 0; vector<pair<int, int> > line; for(int l = 1; l <= n; l++) { long long sum = 0; for(int r = l; r <= n - (l == 1); r++) { sum += a[r]; if (sum < a[l - 1] && sum < a[r + 1]) line.emplace_back(l, r); } } int _x = x, _y = y; long long sum = 0; for(int i = y; i >= x; i--) { if (a[i] > sum) _y = i; sum += a[i]; } sum = 0; for(int i = x; i <= y; i++) { if (a[i] > sum) _x = i; sum += a[i]; } x = _x; y = _y; assert(line.size() <= n); for(int i = x; i <= y; i++) { bool ok = 1; for(auto &[l, r] : line) if (l <= i && i <= r) { if (l >= x || r <= y) ok = 0; } ans += ok; } cout << ans << endl; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | Incorrect | 13 ms | 348 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Execution timed out | 4061 ms | 3572 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | Incorrect | 13 ms | 348 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Execution timed out | 4061 ms | 3572 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Execution timed out | 4061 ms | 3572 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | Incorrect | 13 ms | 348 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |