Submission #1029709

# Submission time Handle Problem Language Result Execution time Memory
1029709 2024-07-21T08:26:24 Z Otalp Fish 2 (JOI22_fish2) C++17
13 / 100
4000 ms 8392 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define ff first
#define ss second

int a[200100];
ll pref[200100];
int ok[200100];

void solve(){
    int n;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        pref[i] = pref[i - 1]  + a[i];
    }
    int t;
    cin>>t;
    while(t--){
        int c;
        cin>>c;
        if(c == 1){
            int x, y;
            cin>>x>>y;
            a[x] = y;
            for(int i=1; i<=n; i++){
                pref[i] = pref[i - 1] + a[i];
            }
        }
        else{
            int l, r;
            cin>>l>>r;
            set<int> pos;
            vector<pii> d;
            int mx = 0;
            for(int i=l; i<=r; i++){
                d.pb({a[i], i});
                ok[i] = 0;
                mx = max(a[i], mx);
            }
            sort(d.begin(), d.end(), greater<pii>());
            for(pii h: d){
                if(h.ff == mx){
                    ok[h.ss] = 1;
                    pos.insert(h.ss);
                    continue;
                }
                int L, R;
                auto it = pos.lower_bound(h.ss);
                if(it == pos.begin()){
                    L = l;
                }
                else{
                    it--;
                    L = *it + 1;
                    it++;
                }
                if(it == pos.end()){
                    R = r;
                }
                else{
                    R = *it - 1;
                }
                ll sum = pref[R] - pref[L - 1];
                if(L > l and ok[L-1] and sum >= a[L-1]) ok[h.ss] = 1;
                if(R < r and ok[R+1] and sum >= a[R+1]) ok[h.ss] = 1;
                pos.insert(h.ss);
            }
            int res = 0;
            for(int i=l; i<=r; i++) res += ok[i];
            cout<<res<<'\n';
        }
    }





            
                

}

signed main(){
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 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 4 ms 348 KB Output is correct
6 Correct 12 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 9 ms 348 KB Output is correct
9 Correct 15 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 18 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 14 ms 500 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 8 ms 348 KB Output is correct
16 Correct 14 ms 348 KB Output is correct
17 Correct 7 ms 348 KB Output is correct
18 Correct 14 ms 348 KB Output is correct
19 Correct 8 ms 348 KB Output is correct
20 Correct 34 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 49 ms 7884 KB Output is correct
3 Correct 41 ms 7620 KB Output is correct
4 Correct 50 ms 7876 KB Output is correct
5 Correct 34 ms 7628 KB Output is correct
6 Correct 63 ms 8388 KB Output is correct
7 Correct 33 ms 7620 KB Output is correct
8 Correct 58 ms 8392 KB Output is correct
9 Correct 34 ms 7632 KB Output is correct
10 Correct 45 ms 7876 KB Output is correct
11 Correct 34 ms 7624 KB Output is correct
12 Correct 36 ms 7620 KB Output is correct
13 Correct 37 ms 7620 KB Output is correct
14 Correct 43 ms 7876 KB Output is correct
15 Correct 44 ms 7872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 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 4 ms 348 KB Output is correct
6 Correct 12 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 9 ms 348 KB Output is correct
9 Correct 15 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 18 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 14 ms 500 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 8 ms 348 KB Output is correct
16 Correct 14 ms 348 KB Output is correct
17 Correct 7 ms 348 KB Output is correct
18 Correct 14 ms 348 KB Output is correct
19 Correct 8 ms 348 KB Output is correct
20 Correct 34 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 49 ms 7884 KB Output is correct
23 Correct 41 ms 7620 KB Output is correct
24 Correct 50 ms 7876 KB Output is correct
25 Correct 34 ms 7628 KB Output is correct
26 Correct 63 ms 8388 KB Output is correct
27 Correct 33 ms 7620 KB Output is correct
28 Correct 58 ms 8392 KB Output is correct
29 Correct 34 ms 7632 KB Output is correct
30 Correct 45 ms 7876 KB Output is correct
31 Correct 34 ms 7624 KB Output is correct
32 Correct 36 ms 7620 KB Output is correct
33 Correct 37 ms 7620 KB Output is correct
34 Correct 43 ms 7876 KB Output is correct
35 Correct 44 ms 7872 KB Output is correct
36 Correct 3369 ms 7932 KB Output is correct
37 Execution timed out 4065 ms 7536 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 49 ms 7884 KB Output is correct
3 Correct 41 ms 7620 KB Output is correct
4 Correct 50 ms 7876 KB Output is correct
5 Correct 34 ms 7628 KB Output is correct
6 Correct 63 ms 8388 KB Output is correct
7 Correct 33 ms 7620 KB Output is correct
8 Correct 58 ms 8392 KB Output is correct
9 Correct 34 ms 7632 KB Output is correct
10 Correct 45 ms 7876 KB Output is correct
11 Correct 34 ms 7624 KB Output is correct
12 Correct 36 ms 7620 KB Output is correct
13 Correct 37 ms 7620 KB Output is correct
14 Correct 43 ms 7876 KB Output is correct
15 Correct 44 ms 7872 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Execution timed out 4088 ms 7624 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 49 ms 7884 KB Output is correct
3 Correct 41 ms 7620 KB Output is correct
4 Correct 50 ms 7876 KB Output is correct
5 Correct 34 ms 7628 KB Output is correct
6 Correct 63 ms 8388 KB Output is correct
7 Correct 33 ms 7620 KB Output is correct
8 Correct 58 ms 8392 KB Output is correct
9 Correct 34 ms 7632 KB Output is correct
10 Correct 45 ms 7876 KB Output is correct
11 Correct 34 ms 7624 KB Output is correct
12 Correct 36 ms 7620 KB Output is correct
13 Correct 37 ms 7620 KB Output is correct
14 Correct 43 ms 7876 KB Output is correct
15 Correct 44 ms 7872 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Execution timed out 4051 ms 8392 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 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 4 ms 348 KB Output is correct
6 Correct 12 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 9 ms 348 KB Output is correct
9 Correct 15 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 18 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 14 ms 500 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 8 ms 348 KB Output is correct
16 Correct 14 ms 348 KB Output is correct
17 Correct 7 ms 348 KB Output is correct
18 Correct 14 ms 348 KB Output is correct
19 Correct 8 ms 348 KB Output is correct
20 Correct 34 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 49 ms 7884 KB Output is correct
23 Correct 41 ms 7620 KB Output is correct
24 Correct 50 ms 7876 KB Output is correct
25 Correct 34 ms 7628 KB Output is correct
26 Correct 63 ms 8388 KB Output is correct
27 Correct 33 ms 7620 KB Output is correct
28 Correct 58 ms 8392 KB Output is correct
29 Correct 34 ms 7632 KB Output is correct
30 Correct 45 ms 7876 KB Output is correct
31 Correct 34 ms 7624 KB Output is correct
32 Correct 36 ms 7620 KB Output is correct
33 Correct 37 ms 7620 KB Output is correct
34 Correct 43 ms 7876 KB Output is correct
35 Correct 44 ms 7872 KB Output is correct
36 Correct 3369 ms 7932 KB Output is correct
37 Execution timed out 4065 ms 7536 KB Time limit exceeded
38 Halted 0 ms 0 KB -