http://acm.hdu.edu.cn/showproblem.php?pid=1873

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std; struct patient
{
int id;
int val;
}; patient p[]; bool operator<(patient p1,patient p2)
{
if(p1.val==p2.val)
return p1.id>p2.id;
return p1.val<p2.val;
}
///优先级高的排在前面,重载操作符出来效果和自定义函数相反
priority_queue<patient>que1,que2,que3; int n;
string s;
int a,b; int main()
{
while(cin>>n)
{
while(que1.size())
que1.pop();
while(que2.size())
que2.pop();
while(que3.size())
que3.pop();
int cnt=;
while(n--)
{
cin>>s;
if( s[]=='I' )
{
cin>>a>>b;///有一个优先级为b的病人要a医生诊治
cnt++;
if( a== )///丢进a医生得队列
que1.push({cnt,b});
if(a==)
que2.push({cnt,b});
if(a==)
que3.push({cnt,b});
}
else
{
cin>>a;///医生a诊断了一个病人,问此人编号,即队列出队
patient now;
if(a==)
{
if(que1.size())
{
now=que1.top();
que1.pop();
cout<<now.id<<endl;
}
else
cout<<"EMPTY"<<endl;
}
else if(a==)
{
if(que2.size())
{
now=que2.top();
que2.pop();
cout<<now.id<<endl;
}
else
cout<<"EMPTY"<<endl;
}
else
{
if(que3.size())
{
now=que3.top();
que3.pop();
cout<<now.id<<endl;
}
else
cout<<"EMPTY"<<endl;
}
} }
}
return ;
}

最新文章

  1. java并发编程系列
  2. HTML5的学习--performance
  3. Scrum敏捷项目管理精要
  4. Python OpenCV —— Arithmetic
  5. 编写高质量代码改善C#程序的157个建议[协变和逆变]
  6. audio.js – 随时随地,播放 HTML5 的声音
  7. ICursor查询后的排序问题
  8. 《HTML5与CSS3基础教程》学习笔记 ——Two Day
  9. 【java基础】--(3)javaIO详细阐释
  10. Object -C self -- 笔记
  11. Window.open 实现导航与打开窗口,导航到一个特定链接地址,也可以打开一个新的浏览器窗体
  12. Eclipse使用git 上传代码至github
  13. 关于Resharper的使用经验
  14. Android自定义底部带有动画的Dialog
  15. 第七周LINUX学习笔记
  16. 第三周 数据分析之概要 Pandas库数据特征分析
  17. Python中的算数运算
  18. RabbitMQ 死信队列 延时
  19. C++ leetcode Longest Substring Without Repeating Characters
  20. 2018/04/07 每日一个Linux命令 之 logrotate

热门文章

  1. 微信小程序绑定列表数据
  2. springboot kafka生产者
  3. Windwos Server 2016 远程桌面授权
  4. Java连载15-boolean类型&amp;类型转换&amp;++运算符
  5. SpringBoot第十八篇:异步任务
  6. Maven 教程(22)— Maven中 plugins 和 pluginManagement
  7. 适配器模式(Adapter Pattern)--设计模式
  8. Redis(四)Pub/Sub
  9. DOM的回流和重绘(重排、重绘)
  10. 【java】javac命令在win10不可用,提示javac不是内部或外部命令,也不是可运行的程序【解决方法】