蜜汁RE求调(玄关)
  • 板块P2073 送花
  • 楼主Const_AKer
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/8/27 20:27
  • 上次更新2024/8/27 22:11:45
查看原帖
蜜汁RE求调(玄关)
1038686
Const_AKer楼主2024/8/27 20:27
#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
int a[N],op,w,c,i;
long long ans,cnt;
priority_queue<int,vector<int>,greater<int>> p_min;
priority_queue<int> p_max;
int main()
{
	while(1)
	{
		cin>>op;
		if(op==1)
		{
			cin>>w>>c;
			if(!a[c]) 
			{
				cnt+=c,a[c]=w;
				p_min.push(c);
				p_max.push(c);	
			}
		}
		if(op==2)
		{
			c=p_max.top();
			p_max.pop();
			cnt-=c;
			a[c]=0;
		}
		if(op==3)
		{
			c=p_min.top();
			p_min.pop();
			cnt-=c;
			a[c]=0;
		}
		if(op==-1)
		{
			for(i=1;i<=1000000;i++) ans+=a[i];
			cout<<ans<<' '<<cnt;
			break;
		}
	}
	return 0;
}
2024/8/27 20:27
加载中...