Submission #940474

#TimeUsernameProblemLanguageResultExecution timeMemory
940474tamir1Growing Trees (BOI11_grow)C++17
0 / 100
1033 ms1508 KiB
#include<bits/stdc++.h> using namespace std; int n,m,i,l,r,c,h,x,mx,ans,cur; char type; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; vector<int> a(2*n+5,0); for(i=1;i<=n;i++){ cin >> x; mx=max(x,mx); a[x]++; } while(m--){ cin >> type; if(type=='C'){ cin >> l >> r; ans=0; for(i=l;i<=r;i++){ ans+=a[i]; } cout << ans << "\n"; } else{ cin >> c >> h; for(i=h;i<=mx;i++){ if(c<=0) break; if(c>=a[i]){ a[i+1]+=a[i]; cur=a[i]; c-=a[i]; a[i]=0; } else{ a[i+1]+=c; cur=c; a[i]-=c; c=0; } } if(a[mx+1]>0) mx++; } } }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...