답안 #951590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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";
        }
    }
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -