#include<iostream>
#include<queue>
using namespace std;
int main()
{
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
int n,x,t;
while(1)
{
priority_queue< int ,vector<int> ,greater<int> > q;
while((scanf("%d",&n),n)!=0)
{
if(n==-1) break;
if(n==1)
{
if(!q.empty())
{
t=q.top();
q.pop();
printf("%d/n",t);
}
}
else
if(n==2)
{
scanf("%d",&x);
q.push(x);
}
}
if(n==-1) break;
printf("/n");
}
return 0;
}
2617: 火热的房地产(使用优先级队列,STL库)
最新推荐文章于 2024-11-25 20:27:26 发布
本文介绍了一个使用 C++ 实现的优先队列操作程序。该程序通过读取输入文件 in.txt 中的数据,根据指令对优先队列进行操作,并将输出结果写入 out.txt 文件中。支持的操作包括:从队列中取出最小元素、向队列中插入指定数值。程序利用了 C++ STL 中的 priority_queue 容器来高效地实现这些功能。
1208

被折叠的 条评论
为什么被折叠?



