# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
937804 | 2024-03-04T13:28:52 Z | nguyentunglam | Fish 2 (JOI22_fish2) | C++17 | 4000 ms | 3820 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; // cout << x << " " << y << endl; // for(auto &[l, r] : line) cout << l << " " << r << endl; 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) { if (l != x && r != y) ok = 0; } } ans += ok; } cout << ans << endl; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 17 ms | 496 KB | Output is correct |
6 | Correct | 42 ms | 344 KB | Output is correct |
7 | Correct | 15 ms | 600 KB | Output is correct |
8 | Correct | 30 ms | 348 KB | Output is correct |
9 | Correct | 48 ms | 468 KB | Output is correct |
10 | Correct | 26 ms | 348 KB | Output is correct |
11 | Correct | 64 ms | 468 KB | Output is correct |
12 | Correct | 13 ms | 504 KB | Output is correct |
13 | Correct | 53 ms | 344 KB | Output is correct |
14 | Correct | 12 ms | 492 KB | Output is correct |
15 | Correct | 46 ms | 600 KB | Output is correct |
16 | Correct | 49 ms | 348 KB | Output is correct |
17 | Correct | 23 ms | 344 KB | Output is correct |
18 | Correct | 50 ms | 348 KB | Output is correct |
19 | Correct | 27 ms | 348 KB | Output is correct |
20 | Correct | 102 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Execution timed out | 4033 ms | 3820 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 17 ms | 496 KB | Output is correct |
6 | Correct | 42 ms | 344 KB | Output is correct |
7 | Correct | 15 ms | 600 KB | Output is correct |
8 | Correct | 30 ms | 348 KB | Output is correct |
9 | Correct | 48 ms | 468 KB | Output is correct |
10 | Correct | 26 ms | 348 KB | Output is correct |
11 | Correct | 64 ms | 468 KB | Output is correct |
12 | Correct | 13 ms | 504 KB | Output is correct |
13 | Correct | 53 ms | 344 KB | Output is correct |
14 | Correct | 12 ms | 492 KB | Output is correct |
15 | Correct | 46 ms | 600 KB | Output is correct |
16 | Correct | 49 ms | 348 KB | Output is correct |
17 | Correct | 23 ms | 344 KB | Output is correct |
18 | Correct | 50 ms | 348 KB | Output is correct |
19 | Correct | 27 ms | 348 KB | Output is correct |
20 | Correct | 102 ms | 344 KB | Output is correct |
21 | Correct | 0 ms | 600 KB | Output is correct |
22 | Execution timed out | 4033 ms | 3820 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Execution timed out | 4033 ms | 3820 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Execution timed out | 4033 ms | 3820 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 17 ms | 496 KB | Output is correct |
6 | Correct | 42 ms | 344 KB | Output is correct |
7 | Correct | 15 ms | 600 KB | Output is correct |
8 | Correct | 30 ms | 348 KB | Output is correct |
9 | Correct | 48 ms | 468 KB | Output is correct |
10 | Correct | 26 ms | 348 KB | Output is correct |
11 | Correct | 64 ms | 468 KB | Output is correct |
12 | Correct | 13 ms | 504 KB | Output is correct |
13 | Correct | 53 ms | 344 KB | Output is correct |
14 | Correct | 12 ms | 492 KB | Output is correct |
15 | Correct | 46 ms | 600 KB | Output is correct |
16 | Correct | 49 ms | 348 KB | Output is correct |
17 | Correct | 23 ms | 344 KB | Output is correct |
18 | Correct | 50 ms | 348 KB | Output is correct |
19 | Correct | 27 ms | 348 KB | Output is correct |
20 | Correct | 102 ms | 344 KB | Output is correct |
21 | Correct | 0 ms | 600 KB | Output is correct |
22 | Execution timed out | 4033 ms | 3820 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |