답안 #815651

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815651 2023-08-08T17:44:46 Z MilosMilutinovic Fish 2 (JOI22_fish2) C++14
5 / 100
4000 ms 724 KB
/**
 *    author:  wxhtzdy
 *    created: 08.08.2023 19:40:14
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);  
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  auto Check = [&](int i, int l, int r) {
    long long s = a[i];
    int L = i, R = i;
    while (L > l || R < r) {
      if (L > l && s >= a[L - 1]) {
        s += a[L - 1];
        L--;
        continue;
      } 
      if (R < r && s >= a[R + 1]) {
        s += a[R + 1];
        R++;
        continue;
      }
      break;
    } 
    return (L == l && R == r);
  };
  int q;
  cin >> q;
  while (q--) {
    int op;
    cin >> op;
    if (op == 1) {
      int x, y;
      cin >> x >> y;
      --x;
      a[x] = y;
    } else {
      int l, r;
      cin >> l >> r;
      --l; --r;
      int res = 0;         
      for (int i = l; i <= r; i++) {
        if (Check(i, l, r)) {
          res += 1;
        }
      }
      cout << res << '\n';
    }
  }                                                  
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 7 ms 324 KB Output is correct
10 Correct 8 ms 336 KB Output is correct
11 Correct 11 ms 332 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 3 ms 328 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 10 ms 324 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 7 ms 328 KB Output is correct
20 Correct 46 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 535 ms 724 KB Output is correct
3 Correct 71 ms 724 KB Output is correct
4 Correct 531 ms 724 KB Output is correct
5 Correct 88 ms 596 KB Output is correct
6 Execution timed out 4061 ms 596 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 7 ms 324 KB Output is correct
10 Correct 8 ms 336 KB Output is correct
11 Correct 11 ms 332 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 3 ms 328 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 10 ms 324 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 7 ms 328 KB Output is correct
20 Correct 46 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 535 ms 724 KB Output is correct
23 Correct 71 ms 724 KB Output is correct
24 Correct 531 ms 724 KB Output is correct
25 Correct 88 ms 596 KB Output is correct
26 Execution timed out 4061 ms 596 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 535 ms 724 KB Output is correct
3 Correct 71 ms 724 KB Output is correct
4 Correct 531 ms 724 KB Output is correct
5 Correct 88 ms 596 KB Output is correct
6 Execution timed out 4061 ms 596 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 535 ms 724 KB Output is correct
3 Correct 71 ms 724 KB Output is correct
4 Correct 531 ms 724 KB Output is correct
5 Correct 88 ms 596 KB Output is correct
6 Execution timed out 4061 ms 596 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 7 ms 324 KB Output is correct
10 Correct 8 ms 336 KB Output is correct
11 Correct 11 ms 332 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 3 ms 328 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 10 ms 324 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 7 ms 328 KB Output is correct
20 Correct 46 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 535 ms 724 KB Output is correct
23 Correct 71 ms 724 KB Output is correct
24 Correct 531 ms 724 KB Output is correct
25 Correct 88 ms 596 KB Output is correct
26 Execution timed out 4061 ms 596 KB Time limit exceeded
27 Halted 0 ms 0 KB -