Submission #596783

# Submission time Handle Problem Language Result Execution time Memory
596783 2022-07-15T04:47:35 Z 반딧불(#8447) Fish 2 (JOI22_fish2) C++17
0 / 100
13 ms 1152 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, q;
int arr[100002];

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%d", &arr[i]);
    scanf("%d", &q);
    while(q--){
        int t, l, r;
        scanf("%d %d %d", &t, &l, &r);
        if(t==1){
            arr[l] = r;
            continue;
        }
        int ans = 0;
        for(int i=l; i<=r; i++){
            int s = i, e = i;
            int score = arr[i];
            while(1){
                if(l<s && score >= arr[s-1]) score += arr[--s];
                else if(e<r && score >= arr[e+1]) score += arr[++e];
                else break;
            }
            if(s==l && e==r) ans++;
        }
        printf("%d\n", ans);
    }
}

Compilation message

fish2.cpp: In function 'int main()':
fish2.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
fish2.cpp:12:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(int i=1; i<=n; i++) scanf("%d", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~
fish2.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
fish2.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d %d %d", &t, &l, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Incorrect 2 ms 312 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 KB Output is correct
2 Incorrect 13 ms 1152 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 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Incorrect 2 ms 312 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 KB Output is correct
2 Incorrect 13 ms 1152 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 KB Output is correct
2 Incorrect 13 ms 1152 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 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Incorrect 2 ms 312 KB Output isn't correct
6 Halted 0 ms 0 KB -