hdu1908map 用法
来源:互联网 发布:英伟达超频软件 编辑:程序博客网 时间:2024/06/06 20:54
Double Queue
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1257 Accepted Submission(s): 620
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.
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
21 20 141 30 321 10 993220
Sample Output
02030100
Source
Southeastern Europe 2007
#include<cstdio>#include<iostream>#include<map>using namespace std;map<int,int> a;int main(){int p,k,c;while(scanf("%d",&c)!=EOF&&c){if(c==1){scanf("%d%d",&k,&p);a[p]=k;}if(c==2){if(a.empty()){cout<<"0"<<endl;}else{cout<<a.rbegin()->second<<endl;a.erase(a.rbegin()->first);}}if(c==3){if(a.empty())cout<<"0"<<endl;else{cout<<a.begin()->second<<endl;a.erase(a.begin());}}}return 0;}
阅读全文
0 0
- hdu1908map 用法
- 用法
- ,, 用法
- 用法
- 用法
- #用法
- ??用法
- !!用法
- CustDialog用法 SimpleAdapter 用法
- hibernate_Restrictions用法 hibernate_Restrictions用法
- extern用法+assert用法
- getParameterValues用法
- rpm用法
- Log4j用法
- NameSpace用法
- sp_executesql 用法
- ShellExecute用法
- getParameterValues用法
- 无废话ExtJs 入门教程八[脚本调试Firefox:firebug]
- 域名解析的记录类型
- 实验四:用可重用的链表模块来实现命令行菜单小程序V2.5
- js中正则表达式小总结
- oracle 12cR2 多列列表分区
- hdu1908map 用法
- 怎么将静态网页放到tomcat服务器,并绑定域名,提供访问?
- 无废话ExtJs 入门教程九[数字字段:NumberField、隐藏字段Hidden、日期字段:DataFiedl]
- C# GridView 如何在没有资料时也可以呈现表头栏位
- chrome-headless使用示例(Python)——打开百度
- 数据结构第一次上机(学生信息管理&线性表&顺序表)
- 【深度分析】Java的反编译
- 【安全牛学习笔记】DNS放大攻击
- 【17年新版】PDF文档的Java库jPDFPrint V2017R1发布 | 新增4K高分辨率显示支持