题面:this
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=5e5+5;
int Q;
int cnt=0;
int a[N],op[N],add[N],kick[N];
struct node{
int member;
int height;
};
queue<node > q;
int mb=-1;
node p,h;
signed main()
{
cin>>Q;
for(int i=1;i<=Q;i++)
{
cin>>op[i];
if(op[i]==2) cin>>add[i];
if(op[i]==3)
{
cin>>kick[i];
cnt=i;
if(mb==-1) mb=kick[i];
}
}
int ans=0;
for(int i=1;i<=cnt;i++)
{
if(op[i]==1) p.member++;
else
{
if(p.member!=0) q.push(p);
p.member=0;
p.height=0;
if(op[i]==2)
{
int n=q.size();
while(n>0)
{
h=q.front();
q.pop();
h.height+=add[i];
if(h.height>=mb) ans+=h.member;
else q.push(h);
n--;
}
}
else
{
int n=q.size();
while(n>0)
{
h=q.front();
q.pop();
if(h.height>=mb) ans+=h.member;
else q.push(h);
n--;
}
cout<<ans;
if(i!=cnt) cout<<endl;
ans=0;
mb=kick[i];
}
}
}
return 0;
}