Submission #1063532

# Submission time Handle Problem Language Result Execution time Memory
1063532 2024-08-17T20:02:39 Z YassirSalama Fish 2 (JOI22_fish2) C++17
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int q;
    cin>>q;
    while(q--){
        int t;
        cin>>t;
        if(t==1){
            int i;cin>>i;i--;
            int x;cin>>x;
            v[i]=x;
        }else{
            int ans=0;
            int l,r;cin>>l>>r,l--,r--;
            for(int i=l;i<=r;i++){
                int s=v[i];
                int a=i-1;
                int b=i+1;
                int c=1;
                while(true){
                    bool ok=true;
                    if(a>=l&&s>=v[a]){
                        ok=false;
                        s+=v[a];a--;
                        c++;
                    }
                    if(b<=r&&s>=v[b]){
                        b++;
                        s+=v[b];
                        c++;
                        ok=0;
                    }
                    if(ok) break;
                }
                ans+=c==(r-l+1);
            }
            cout<<ans<<endl;

        }
    }
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -