Problem Description
The new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest, equipped with a modern computing environment provided by IBM Romania, and using modern information technologies. As usual, each client of the
bank is identified by a positive integer K and, upon arriving to the bank for some services, he or she receives a positive integer priority P. One of the inventions of the young managers of the bank shocked the software engineer of the serving system. They
proposed to break the tradition by sometimes calling the serving desk with the lowest priority instead of that with the highest priority. Thus, the system will receive the following types of request:



Your task is to help the software engineer of the bank by writing a program to implement the requested serving policy.


 
Input
Each line of the input contains one of the possible requests; only the last line contains the stop-request (code 0). You may assume that when there is a request to include a new client in the list (code 1), there is no other request
in the list of the same client or with the same priority. An identifier K is always less than 106, and a priority P is less than 107. The client may arrive for being served multiple times, and each time may obtain a different priority.


 
Output
For each request with code 2 or 3, the program has to print, in a separate line of the standard output, the identifier of the served client. If the request arrives when the waiting list is empty, then the program prints zero (0) to
the output.


 
Sample Input
2
1 20 14
1 30 3
2
1 10 99
3
2
2
0
 
Sample Output
0
20
30
10
0 STL乃神器。set的使用。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<limits.h>
#include<set>
using namespace std;
struct node{
int v,p;
bool operator<(const node &a)const//p大的优先
{ return p>a.p; }
}; int main()
{
int u;
set<node>q;
node temp;
while(~scanf("%d",&u))
{
if(u==0)
break;
if(u==1)
{
scanf("%d%d",&temp.v,&temp.p);
q.insert(temp);
}
else if(q.empty())
puts("0");
else if(u==2)
{
printf("%d\n",q.begin()->v);
q.erase(q.begin());
}
else
{
set<node>::iterator it=q.end();
it--;
printf("%d\n",it->v);
q.erase(it);
}
}
return 0;
}

HDU 1908 Double Queue(set)的更多相关文章

  1. hdu 1908 Double Queue

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1908 Double Queue Description The new founded Balkan ...

  2. POJ 3481 &amp; HDU 1908 Double Queue (map运用)

    题目链接: PKU:http://poj.org/problem?id=3481 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1908 Descript ...

  3. hdu 1387 Team Queue (链表)

    题目大意: 不同的人在不同的队伍里,插入链表的时候假设这个链表里有他的队友,就把它放到最后一个队友的最后.假设没有队友,就把它放到整个链表的最后面. 出链表的时候把第一个人拿出来. 思路分析: 要模拟 ...

  4. HDU 5938 Four Operations(四则运算)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  5. HDU 5775 Bubble Sort(冒泡排序)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  6. HDU 1711 Number Sequence(数列)

    HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...

  7. HDU 1005 Number Sequence(数列)

    HDU 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...

  8. 【CF618F】Double Knapsack(构造)

    [CF618F]Double Knapsack(构造) 题面 洛谷 Codeforces 题解 很妙的一道题. 发现找两个数集很不爽,我们强制加强限制,我们来找两个区间,使得他们的区间和相等. 把区间 ...

  9. HDU 1176 免费馅饼 (动态规划)

    HDU 1176 免费馅饼 (动态规划) Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼.说来gameboy的人品实在是太好了,这馅饼 ...

随机推荐

  1. 解决打开MATLAB时出现“Waring:could not read file classpath.txt”,等问题

    估计刚安装好的matlab是不会出现这个问题的,出现问题肯定是在某一次用360或者电脑管家清理垃圾之后才会出现这个问题. 首先声明我的matlab版本是matlab R2014a,下载链接:(额,网盘 ...

  2. App网络管理

    安卓开发一般都需要进行日志管理,常用操作老司机已为你封装完毕,你可以用这份工具进行管理,具体可以查看源码,现在为你开车,Demo传送门. 站点 系统日志输出工具类 → AppKeyBoardMgr g ...

  3. spring boot + thymeleaf 3 国际化

    在给spring boot 1.5.6 + thymeleaf 3进行国际化时,踩了一个坑(其实不止一个). 现象: 看到了吧, 就是取值的key, 后面被加了_en_US 或 _zh_CN, 以及前 ...

  4. 在游览器上可以连网,Ionic打包后不能连接网络

    在游览器上可以连网,Ionic打包后不能连接网络.可能是没有安装cordova-plugin-whitelist插件.  解决方案:

  5. maven构建SSM--pox.mxl

    最近在做项目,把maven构建SSM的pom.xml文件内容小结一下: 在console中输入如下内容,使用maven创建java web项目: mvn archetype:generate -Dgr ...

  6. SQL server中事务的四个属性特征(ACID)

    事务的概念.类型和四个特征(ACID). 1.事务(Transaction)是并发控制的单位,是用户定义的一个操作序列.这些操作要么都做,要么都不做,是一个不可分割的工作单位. 通过事务,SQL Se ...

  7. 自定义view-滑动开关

    介绍 前段时间,我看到了一篇关于可滑动开关Switch组件的文章,效果图如下: 思路也挺简单的:这个控件主要由田径场式背景和滑块组成.他将田径场式背景分为3部分,最左边的半圆,中间的两条直线部分和最右 ...

  8. Facebook-Haystack合并小文件

    1.原文 https://www.usenix.org/legacy/event/osdi10/tech/full_papers/Beaver.pdf 2.翻译版 http://www.importn ...

  9. [转]如何监测谁用了SQL Server的Tempdb空间

    Tempdb 系统数据库是一个全局资源,供连接到 SQL Server 实例的所有用户使用.在现在的SQL Server里,其使用频率可能会超过用户的想象.如果Tempdb空间耗尽,许多操作将不能完成 ...

  10. Api管理工具(spring-rest-docs)

    对于app开发来说,必须需要有相应的api文档,一般最基础的就是用markdown工具来撰写api文档.当对于开发人员来说,是总会想着寻找更方便撰写,测试,对接前端开发的文档生成的工具. 其实这方面的 ...