Submission #940462

#TimeUsernameProblemLanguageResultExecution timeMemory
940462tamir1Growing Trees (BOI11_grow)C++17
0 / 100
1040 ms3048 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; } } } } }
#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...