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的人品实在是太好了,这馅饼 ...
随机推荐
- C# orderby子句
注意:对联接运算的结果进行排序. 请注意,排序在联接之后执行. 虽然可以在联接之前将 orderby 子句用于一个或多个源序列,不过通常不建议这样做. 某些 LINQ 提供程序可能不会在联接之后保留该 ...
- 数据库集群 MySQL主从复制
MySQL主从复制 本节内容我们联系使用MySQL的主从复制功能配置Master和Slave节点,验证数据MySQL的数据同步功能. 因为要使用多个MySQL数据库,所以不建议在电脑上安装多个MySQ ...
- Problem F: 分数类的类型转换
Description 封装一个分数类Fract,用来处理分数功能和运算,支持以下操作: 1. 构造:传入两个参数n和m,表示n/m:分数在构造时立即转化成最简分数. 2. show()函数:分数 ...
- 【框架学习与探究之日志组件--Log4Net与NLog】
前言 本文欢迎转载,作者原创地址:http://www.cnblogs.com/DjlNet/p/7604340.html 序 近日,天气渐冷,懒惰的脑虫又开始作祟了,导致近日内功修炼迟迟未能进步,依 ...
- 记一次list循环删除元素的突发事件!
事情是这样的,由于想再回顾一下基础,就写了一个main函数,里面循环删元素的代码.如下: List<String> a = new ArrayList<String>(); a ...
- 获取所有栈的信息,只有最上面的和最下面的,但是不能获取栈中间的activity信息
直接在cmd窗口上输入 adb shell后,再输入dumpsys activity activities,可以看到所有的activity以及相关栈状态
- 开篇-我眼中的FPGA
既然是开篇,那就来闲话叨一叨FPGA吧. 掰掰指头,结识FPGA估计有5年多.作为嵌入式工程师,每天的日常充斥着ARM.DSP.操作系统.通讯.总线等耳熟能详的词汇,徜徉其中不能自拔,而这其中,自觉最 ...
- python 中 urlparse 模块介绍
urlparse模块主要是用于解析url中的参数 对url按照一定格式进行 拆分或拼接 1.urlparse.urlparse 将url分为6个部分,返回一个包含6个字符串项目的元组:协议.位置.路 ...
- python进阶------进程线程(四)
Python中的协程 协程,又称微线程,纤程.英文名Coroutine.一句话说明什么是线程:协程是一种用户态的轻量级线程. 协程拥有自己的寄存器上下文和栈.协程调度切换时,将寄存器上下文和栈保存到其 ...
- maven学习之1
最近用maven的时候各种出问题,打算系统的学习一下maven,搞明白依赖之类的. (一)创建工程: mvn archetype:generate 这样就可以根据提示来建立一个maven项目,常用的有 ...