HDU 1908 Double Queue(set)
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.
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.
the output.
2
1 20 14
1 30 3
2
1 10 99
3
2
2
0
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)的更多相关文章
- hdu 1908 Double Queue
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1908 Double Queue Description The new founded Balkan ...
- POJ 3481 & HDU 1908 Double Queue (map运用)
题目链接: PKU:http://poj.org/problem?id=3481 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1908 Descript ...
- hdu 1387 Team Queue (链表)
题目大意: 不同的人在不同的队伍里,插入链表的时候假设这个链表里有他的队友,就把它放到最后一个队友的最后.假设没有队友,就把它放到整个链表的最后面. 出链表的时候把第一个人拿出来. 思路分析: 要模拟 ...
- HDU 5938 Four Operations(四则运算)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 5775 Bubble Sort(冒泡排序)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 1711 Number Sequence(数列)
HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- HDU 1005 Number Sequence(数列)
HDU 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...
- 【CF618F】Double Knapsack(构造)
[CF618F]Double Knapsack(构造) 题面 洛谷 Codeforces 题解 很妙的一道题. 发现找两个数集很不爽,我们强制加强限制,我们来找两个区间,使得他们的区间和相等. 把区间 ...
- HDU 1176 免费馅饼 (动态规划)
HDU 1176 免费馅饼 (动态规划) Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼.说来gameboy的人品实在是太好了,这馅饼 ...
随机推荐
- JavaNIO阻塞IO
package com.java.NIO; import java.io.IOException; import java.net.InetSocketAddress; import java.nio ...
- Android 开发笔记___Activity的生命周期
一个activity就是一个页面,入口函数是oncreate(). onCreate:创建页面,把页面上各个元素加载到内存 onStart:开始页面,把页面显示在屏幕 onResume:恢复页面,让页 ...
- grunt任务自动管理
Grunt管理工具使用: 一.模块安装 1.在项目的根目录里新建package.json文件,形式如下,指定依赖的库以及版本信息. 2.然后在项目根目录下,执行 npm install ,安装json ...
- 解决autocad闪退
1.进入注册表,regedit 2.找到ROOT\installer\Products ,找到以7D2F开头的键值,这里有两个都得删除 3.删除programdata目录下的AutoDesk目录,及f ...
- win10出现"本地计算机上的MySQL57服务启动后停止"
在window10下mysql57出现"本地计算机上的MySQL57服务启动后停止.某些服务在未由其他服务或程序使用时将自动停止"错误 环境:win10.MySQL Communi ...
- hadoop启动name失败
namenode失败十分的常见, 1.java.io.EOFException; Host Details : local host is: "hadoop1/192.168.41.134& ...
- APP后台API文档管理对接(APP后台框架五)
这一章还是总结点API管理工具,也大都是组件来的,关于spring-rest-doc 以为很不错,其实还是有点局限性的: 1,每一个接口文档,都要自己手动设置文档的展示: 2,每一个接口就独立一个文档 ...
- node.js安装——Windows7系统下的安装及其环境部署——特别详细
作为一个前端的菜鸟同学,之间也没学过什么框架,目前公司做项目,所用到的webpack+node.js+vue. 首先,关于node的环境部署方面,建议官网安装node.js,最好不要安装非稳定版的版本 ...
- kali 2.0中msf连接postgres数据库
装好kali 2.0后直接运行msfconsole msf> db_status postgres selected, no connection 百度到的解决方法多是针对BT和kali 1.0 ...
- Less的内置函数
杂项函数 color 解析颜色,将代表颜色的字符串转换为颜色值. 参数: string: 代表颜色值的字符串. 返回值: color 案例: color("#aaa"); 输出: ...