AT_abc379_d 题解
题目传送门
思路
首先,不难考虑到
然后,想到操作 2 中可以增加一个变量控制增长的高度
最后,使用优先队列降低复杂度。在操作 3 中,每次都删到比
注意事项
- 不开
long long见祖宗。
AC CODE
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read(){int x=0;char f=1,ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}
priority_queue<int/*,vector<int>,greater<int>*/>pq;
signed main(){
int q=read(),h=0;
while(q--){
int op=read();
if(op==1)
pq.push(-h);
else if(op==2)
h+=read();
else{
int x=read(),ans=0;
while(!pq.empty()){
int temp=pq.top();
if(temp+h>=x)
++ans,pq.pop();
else break;
}
printf("%lld\n",ans);
}
}
return 0;
}