为什么会有RE
  • 板块P2073 送花
  • 楼主Lips
  • 当前回复15
  • 已保存回复15
  • 发布时间2020/8/3 09:57
  • 上次更新2023/11/6 21:26:40
查看原帖
为什么会有RE
342090
Lips楼主2020/8/3 09:57

萌新 setset 求助!(不用看超时,就是想知道为神马 RE\texttt{RE}

#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
const int MAXN=100010;
typedef long long ll;
int type,n;
typedef pair<ll,ll> P;
struct node
{
	ll value,price;
	bool operator <(const node&a) const
	{
		return a.price>price;
	}
};
set<node>st;
node make(ll value,ll price){node ans;ans.price=price,ans.value=value;return ans;}
void sum()
{
	node ans;
	ans.value=ans.price=0;
	for(register set<node>::iterator it=st.begin();it!=st.end();it++)
	{
		node a=*it;
		ans.value+=a.value,ans.price+=a.price;
	}
	printf("%lld %lld\n",ans.value,ans.price);
	exit(0);
}
void print()
{
	for(register set<node>::iterator it=st.begin();it!=st.end();it++)
	{
		node a=*it;
		printf("%lld %lld\n",a.value,a.price);
	}
}
void pre()
{
	while(true)
	{
		scanf("%d",&type);
		if(type==-1)
		{
			if(st.size()==0) continue;
			else sum();
		}
		else
		{
			if(type==1)
			{
				ll v,p;
				scanf("%lld%lld",&v,&p);
				st.insert(make(v,p));
			}
			else
			{
				if(type==3) st.erase(st.begin());
				else st.erase(--st.end());
			}
		}
	}
}
int main()
{
	pre();
}
2020/8/3 09:57
加载中...