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 ;
}

hdu1873-看病要排队-(结构体优先队列)的更多相关文章

  1. HDU1873 看病要排队【模拟+优先队列】

    看病要排队 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  2. hdu1873 看病要排队(结构体优先队列)

    看病要排队 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  3. hdu1873 看病要排队【优先队列】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1873 看病要排队 Time Limit: 3000/1000 MS (Java/Others)     ...

  4. hdu1873 看病要排队 优先队列

    看病要排队 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  5. hdu 1872(看病要排队)(优先队列)

    看病要排队 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  6. HDU-1873 看病要排队(队列模拟)

    看病要排队 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  7. HDU1873 看病要排队 —— 优先队列(STL)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1873 题解: 题目已经说出了解题方法:优先队列.但是之前没有学过优先队列,而且这题还是在现场赛做的.由 ...

  8. hdoj 1873 看病要排队【优先队列】

    看病要排队 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  9. hdu1837 看病要排队(优先队列)

    看病要排队 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

随机推荐

  1. js 立即调用函数 IIFE(Immediately Invoked Function Expression) 【转】

    原文链接:https://www.cnblogs.com/ming-os9/p/8891300.html JS中 (function(){...})()立即执行函数   1 (function(){. ...

  2. Spring Cloud(十四):Ribbon实现客户端负载均衡及其实现原理介绍

    年后到现在一直很忙,都没什么时间记录东西了,其实之前工作中积累了很多知识点,一直都堆在备忘录里,只是因为近几个月经历了一些事情,没有太多的经历来写了,但是一些重要的东西,我还是希望能坚持记录下来.正好 ...

  3. vertica 中位数函数 MEDIAN 的使用

    中位数函数:MEDIAN 使用表达式:MEDIAN ( expression ) OVER ( [ window‑partition‑clause ] ) 准备测试数据: ), name ), sal ...

  4. scala练习题--万年历

     使用方法去完成 import scala.io.StdIn object work1 { def main(args: Array[String]): Unit = { // 1.先输出提示语句,并 ...

  5. 百度前端技术学院task1 总结

    1.居中:当使用text-align或者vatical-align无法达到居中的时候,如果知道元素的大小,可以采用先设为left或right为50%,再设置margin-left或者margin-ri ...

  6. Java学习:IO流

    IO流 1.IO流 用于处理设备上的数据. 设备:硬盘,内存,键盘录入. 2. IO有具体的分类: 根据处理的数据类型不同:字节流和字符流. 根据流向不同:输入流和输出流. 字符流的由来: 因为文件编 ...

  7. WPF 精修篇 路径动画

    原文:WPF 精修篇 路径动画 路径动画 是让一个对象围绕指定Path 的运动路径 进行移动的动画 举栗子 路径动画 使用 Blend 来设置 是十分简单的 首先用工具 笔  点出一条线 新建一个圆形 ...

  8. 排序算法Java代码实现(四)—— 归并排序

    本篇内容: 归并排序 归并排序 算法思想: 将两个或两个以上的有序表合并成一个新的有序表, 即把待排序序列分成若干个子序列,每个子序列是有序的,然后在把有序子序列合并为整体有序序列. 此算法分为两步: ...

  9. HTML5 下拉控件绑定数据

    <select id="CommunityList" class="form-control" > <option>請選擇社團</ ...

  10. 求x到y的最少计算次数

    链接:https://www.nowcoder.com/questionTerminal/45d04d4d047c48768543eeec95798ed6?orderByHotValue=1& ...