uva1598(大模拟+优先队列)

该博客主要探讨了如何解决UVa1598问题,通过详细模拟过程来阐述解题思路。文章提到了在实现过程中可能遇到的坑点,如一个订单可能需要多次删除以及优先队列中top()函数返回副本的细节。通过阅读,读者可以了解到如何巧妙地运用优先队列来解决此类问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

思路:照着模拟就行

坑点:一个订单可能会被删除多次,还有一个点。。。优先队列的top函数,返回的是一个copy。。。

代码如下:

/*

*/
#define LOCAL
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
#include<vector>
#include<set>
#include<map>
using namespace std;
#define maxn 10010
#define inf 40000000
#define LL long long
struct BUY
{
	int size,price;//买量,买价
	int id;//进入的编号
	bool operator <(const BUY &rhs) const
	{
		if(price==rhs.price) return id>rhs.id;
		return price<rhs.price;//买价要最高 
	} 
};
struct SELL
{
	int size,price;//卖量,卖价
	int id;//进入的编号
	bool operator <(const SELL &rhs) const
	{
		if(price==rhs.price) return id>rhs.id;
		return price>rhs.price;//卖价要最低 
	} 
}; 
struct node
{
	int cancel;//是否被删除
	int size;//数量 
	int price;//价值 
	char op;
};
int main()
{
	#ifdef LOCAL
	//freopen("data.in","r",stdin);
//	freopen("data.out","w",stdout);
	#endif
	int Case=0,q;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值