Submission #815649

# Submission time Handle Problem Language Result Execution time Memory
815649 2023-08-08T17:43:58 Z MilosMilutinovic Fish 2 (JOI22_fish2) C++14
0 / 100
13 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) {
    int 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;
}
# Verdict Execution time Memory 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 Incorrect 3 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 13 ms 724 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Incorrect 3 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 13 ms 724 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 13 ms 724 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Incorrect 3 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -