hdu1873-看病要排队-(结构体优先队列)
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-看病要排队-(结构体优先队列)的更多相关文章
- HDU1873 看病要排队【模拟+优先队列】
看病要排队 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- hdu1873 看病要排队(结构体优先队列)
看病要排队 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- hdu1873 看病要排队【优先队列】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1873 看病要排队 Time Limit: 3000/1000 MS (Java/Others) ...
- hdu1873 看病要排队 优先队列
看病要排队 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- hdu 1872(看病要排队)(优先队列)
看病要排队 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- HDU-1873 看病要排队(队列模拟)
看病要排队 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- HDU1873 看病要排队 —— 优先队列(STL)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1873 题解: 题目已经说出了解题方法:优先队列.但是之前没有学过优先队列,而且这题还是在现场赛做的.由 ...
- hdoj 1873 看病要排队【优先队列】
看病要排队 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdu1837 看病要排队(优先队列)
看病要排队 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
随机推荐
- vue系列--vue是如何实现绑定事件
一.前言 vuejs中的事件绑定,使用<v-on:事件名 = 函数名>来完成的,这里函数名是定义在Vue实例中的methods对象中的,Vue实例可以直接访问其中的方法. 二.事件绑定方式 ...
- (九)golang--标识符的命名规则
标识符的概念: (1)各种变量.方法等命名时使用的字符序列被称为标识符: (2)凡是可以自己起名字的都可以叫标识符: 标识符的命名规则: (1)由26个英文字母大小写,0-9,_组成 (2)数字不可以 ...
- CentOS7部署vsftpd服务
1.查看是否已经安装了vsftpd vsftpd -version 2.安装vsftpd(CentOS7) yum install -y vsftpd 3.新建FTP目录 创建的FTP目录如下: /d ...
- 获取豆瓣电影数据(R与API获取网页数据)
一般成熟的网站都会有反爬虫策略,例如限制访问次数,限制访问 IP,动态显示数据等.爬虫和反爬虫就是一直相爱相杀地互相钳制.如果要通过爬虫来获取某些大型网站的数据,那是一件很费时费力的活.小白总遭遇过在 ...
- json工具类(三)——net包
package com.ruoyi.common.utils.json; import java.util.List; import java.util.Map; import net.sf.json ...
- Django学习——全局templates引用的问题
一.问题在构建网站的时候我们会用到全局的templates处理错误的网页,此时我们需要对urls进行一个映射,使得在使用的时候避免重复调用.在使用的时候还会产生错误代码:第一个是404界面的,第二个是 ...
- Python的设计哲学--zen of Python
Python的设计哲学--zen of Python Beautiful is better than ugly. 优美胜于丑陋 Explicit is better than ...
- Canon MF113W激光打印机双面打印方法
系统:macOS 10.14.3 打印机:Canon MF113W 黑白激光打印机(不支持自动双面打印) 方法: 1)文件->打印->纸张处理->仅奇数页->倒序->打印 ...
- 关于thinkphp3.2.3集成phpmailer
关于thinkphp3.2.3集成phpmailer 1 我用的是phpmailer5.1的版本 先把文件解压缩放到这个位置 2 封装到函数里面 function email($email,$tit ...
- MD5加密方法HashPasswordForStoringInConfigFile(string,string)过时问题处理方法
最近写代码的时候一直有一种很奇怪的感觉,查了一下发现原来是系统中的MD5加密方法报了过时的警告,虽然对系统没有任何影响,但是开发过程中绿色波浪线就像挥之不去的阴影一样.开发人员多多少少都会有点强迫症, ...