답안 #937737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937737 2024-03-04T12:17:12 Z nguyentunglam Fish 2 (JOI22_fish2) C++17
5 / 100
4000 ms 1628 KB
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define endl "\n"
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;

  while (q--) {
    int t, x, y; cin >> t >> x >> y;
    if (t == 1) a[x] = y;
    else {
      int ans = 0;
      for(int i = x; i <= y; i++) {
        int l = i - 1, r = i + 1, ok = 1;
        long long cur = a[i];
        while (l >= x || r <= y) {
          if (l >= x && a[l] <= cur) cur += a[l--];
          else if (r <= y && a[r] <= cur) cur += a[r++];
          else {
            ok = 0;
            break;
          }
        }
        ans += ok;
      }
      cout << ans << endl;
    }
  }
}



Compilation message

fish2.cpp: In function 'int32_t main()':
fish2.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen("task.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
fish2.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen("task.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
fish2.cpp:21:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen (task".inp", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
fish2.cpp:22:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen (task".out", "w", stdout);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 11 ms 348 KB Output is correct
12 Correct 1 ms 472 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 9 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 27 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 449 ms 604 KB Output is correct
3 Correct 53 ms 1164 KB Output is correct
4 Correct 469 ms 1412 KB Output is correct
5 Correct 54 ms 1116 KB Output is correct
6 Execution timed out 4046 ms 1628 KB Time limit exceeded
7 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 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 11 ms 348 KB Output is correct
12 Correct 1 ms 472 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 9 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 27 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 449 ms 604 KB Output is correct
23 Correct 53 ms 1164 KB Output is correct
24 Correct 469 ms 1412 KB Output is correct
25 Correct 54 ms 1116 KB Output is correct
26 Execution timed out 4046 ms 1628 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 449 ms 604 KB Output is correct
3 Correct 53 ms 1164 KB Output is correct
4 Correct 469 ms 1412 KB Output is correct
5 Correct 54 ms 1116 KB Output is correct
6 Execution timed out 4046 ms 1628 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 449 ms 604 KB Output is correct
3 Correct 53 ms 1164 KB Output is correct
4 Correct 469 ms 1412 KB Output is correct
5 Correct 54 ms 1116 KB Output is correct
6 Execution timed out 4046 ms 1628 KB Time limit exceeded
7 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 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 11 ms 348 KB Output is correct
12 Correct 1 ms 472 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 9 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 27 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 449 ms 604 KB Output is correct
23 Correct 53 ms 1164 KB Output is correct
24 Correct 469 ms 1412 KB Output is correct
25 Correct 54 ms 1116 KB Output is correct
26 Execution timed out 4046 ms 1628 KB Time limit exceeded
27 Halted 0 ms 0 KB -