80分!!!!
  • 板块P2073 送花
  • 楼主StObOtZ
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/3/12 11:24
  • 上次更新2023/10/28 06:48:02
查看原帖
80分!!!!
188104
StObOtZ楼主2022/3/12 11:24
#include<bits/stdc++.h>
//#define int long long
using namespace std;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
priority_queue<pair<int,int> > q1;
//struct node{
//	int x,int y
//};
inline int read(){
	int x=0,m=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') m=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=x*10+ch-48;
		ch=getchar();
	}
	return x*m;
}
inline void write(int x){
	if(x < 0){
		putchar('-');
		write(-x);
		return;
	}
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
inline void writesp(int x){
	write(x);
	putchar(' ');
}
inline void writeln(int x){
	write(x);
	putchar('\n');
}
int w,c,n;
map<int,int> Map;
signed main(){
    //int n=read();
    cin>>n;
	while (n!=-1){
		if (n==1){
			cin>>w>>c;
			if (Map[c]==0){
				Map[c]=1;
				q.push(make_pair(c,w));
				q1.push(make_pair(c,w));
			}
		}
		if (n==2){
			while (!q1.empty()&&Map[q1.top().first]==0) q1.pop();
			if (!q1.empty()){
			Map[q1.top().first]=0;
			q1.pop(); }
		}
		if (n==3){
			while (!q.empty()&&Map[q.top().first]==0) q.pop();
			if (!q.empty()){
			Map[q.top().first]=0;
			q.pop(); }
		}
		cin>>n;
	}
	int sum=0,sum1=0;
	while (!q1.empty()){
		if (Map[q1.top().first]==1){
			sum1+=q1.top().first;
			sum+=q1.top().second;
		}
		q1.pop();
	}
	cout<<sum<<" "<<sum1;
//	writesp(sum);
//	write(sum1);
}



2022/3/12 11:24
加载中...