Submission #710296

# Submission time Handle Problem Language Result Execution time Memory
710296 2023-03-15T06:45:55 Z PixelCat Fish 2 (JOI22_fish2) C++14
5 / 100
25 ms 2644 KB
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define int LL
using namespace std;
using LL = long long;
using pii = pair<int, int>;

const int MAXN = 100010;

int a[MAXN];

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // =^-w-^=
    int n; cin >> n;
    For(i, 1, n) cin >> a[i];
    int q; cin >> q;
    assert(max(n, q) <= 500);
    while(q--) {
        int op; cin >> op;
        int L, R; cin >> L >> R;
        if(op == 1) {
            a[L] = R;
            continue;
        }
        int ans = 0;
        For(s, L, R) {
            int l, r; l = r = s;
            int sum = a[s];
            bool upd = true;
            while(upd) {
                upd = false;
                if(l > L && sum >= a[l - 1]) {
                    l--;
                    sum += a[l];
                    upd = true;
                } else if(r < R && sum >= a[r + 1]) {
                    r++;
                    sum += a[r];
                    upd = true;
                }
            }
            if(l == L && r == R) ans++;
        }
        cout << ans << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 3 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 6 ms 344 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 10 ms 340 KB Output is correct
12 Correct 2 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 3 ms 340 KB Output is correct
16 Correct 8 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 4 ms 332 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 25 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 10 ms 2644 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 3 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 6 ms 344 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 10 ms 340 KB Output is correct
12 Correct 2 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 3 ms 340 KB Output is correct
16 Correct 8 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 4 ms 332 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 25 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Runtime error 10 ms 2644 KB Execution killed with signal 6
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 10 ms 2644 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 10 ms 2644 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 3 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 6 ms 344 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 10 ms 340 KB Output is correct
12 Correct 2 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 3 ms 340 KB Output is correct
16 Correct 8 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 4 ms 332 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 25 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Runtime error 10 ms 2644 KB Execution killed with signal 6
23 Halted 0 ms 0 KB -