HDU 1873 看病要排队
来源:互联网 发布:sqlplus连接远程数据库 编辑:程序博客网 时间:2024/05/16 10:31
题目地址:点击打开链接
思路:注意每次把队列清空就行
AC代码:
#include <iostream>#include <queue>using namespace std;struct doctor{ int priority; int num; bool operator < (const doctor & x) const { if(priority != x.priority) return priority < x.priority; //最大值优先 else return num > x.num;//最小值优先 }};int main(){ priority_queue<doctor> pq1,pq2,pq3; string s; doctor in,out; int n,i; int a,b,k; while(cin>>n) { while(!pq1.empty())//注意是while不是if pq1.pop(); while(!pq2.empty()) pq2.pop(); while(!pq3.empty()) pq3.pop(); k = 1; for(i=0; i<n; i++) { cin>>s; if(s == "IN") { cin>>a>>b; in.priority = b; in.num = k++; if(a == 1) { pq1.push(in); } else if(a == 2) { pq2.push(in); } else { pq3.push(in); } } else { cin>>a; if(a == 1) { if(pq1.empty()) cout<<"EMPTY"<<endl; else { out = pq1.top(); pq1.pop(); cout<<out.num<<endl; } } if(a == 2) { if(pq2.empty()) cout<<"EMPTY"<<endl; else { out = pq2.top(); pq2.pop(); cout<<out.num<<endl; } } if(a == 3) { if(pq3.empty()) cout<<"EMPTY"<<endl; else { out = pq3.top(); pq3.pop(); cout<<out.num<<endl; } } } } } return 0;}
0 0
- hdu 1873 看病要排队
- hdu 1873 看病要排队
- hdu 1873(看病要排队)
- HDU 1873 看病要排队
- hdu 1873 看病要排队
- HDU 1873 看病要排队
- HDU 1873看病要排队
- hdu 1873 看病要排队
- HDU 1873 看病要排队
- HDU-1873-看病要排队
- HDU 1873 看病要排队
- HDU 1873 看病要排队
- hdu 1873 看病要排队
- HDU 1873 看病要排队
- hdu 1873 看病要排队
- HDU 1873 看病要排队
- hdu 1873 看病要排队
- HDU 1873 看病要排队
- oracle 字符串中取数字
- Js学习第三天----字符集
- 编译报错解决。
- springMvc 将对象json返回时自动忽略掉对象中的特定属性的注解方式
- python正则表达式
- HDU 1873 看病要排队
- Path Sum II
- UIScrollView和UIPageControl
- java 中的观察者模式
- uva 1103 dfs
- 啊哈,算法!-----dfs3
- 别误用IsDigit与IsNumber函数
- OpenCV中计算二值图像的重心
- Maven(一)简介和基本安装使用