This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |