Submission #951586

#TimeUsernameProblemLanguageResultExecution timeMemory
951586LittleOrangeFish 2 (JOI22_fish2)C++17
0 / 100
1 ms348 KiB
#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; for(ll i = 0;i<w;i++){ ll to = i; while(to<w-1&&u[to]>=v[to+1]) to++; //cout << i << " to " << to << "\n"; if (to==w-1){ left = i; //cout << "left=" << left << " w=" << w << "\n"; break; } i = to; } cout << (w-left) << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...