Submission #951590

# Submission time Handle Problem Language Result Execution time Memory
951590 2024-03-22T07:08:03 Z LittleOrange Fish 2 (JOI22_fish2) C++17
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll &i : a) cin >> i;
    ll q;
    cin >> q;
    while(q--){
        ll ty;
        cin >> ty;
        if(ty==1){
            ll x,y;
            cin >> x >> y;
            a[x-1] = y;
        }else{
            ll l,r;
            cin >> l >> r;
            l--;r--;
            vector<ll> v;
            for(ll i = l;i<=r;i++) v.push_back(a[i]);
            sort(v.begin(),v.end());
            ll w = r-l+1;
            vector<ll> u(w);
            u[0] = v[0];
            for(ll i = 1;i<w;i++) u[i]=v[i]+u[i-1];
            //cout << "got";for(ll i : v) cout << " " << i; cout << "\n";
            //cout << "pre";for(ll i : u) cout << " " << i; cout << "\n";
            ll left = w-1;
            while(left>0&&u[left-1]>=v[left]) left--;
            cout << (w-left) << "\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 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 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -