HDU 1873 看病要排队(优先队列)
2016-02-16 18:16
369 查看
题目:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=32590
代码:
代码:
#include<stdio.h> #include<queue> #include<string.h> using namespace std; struct node { int num; int a,b; friend bool operator <(node x,node y) { if(x.b==y.b)return x.num>y.num; else return x.b<y.b; } }; int main() { int t,g,aa,bb; node va,vb; while(~scanf("%d",&t)) { int k=1; priority_queue<node>q[4]; char str[10]; while(t--) { scanf("%s",str); if(strcmp(str,"IN")==0) { scanf("%d%d",&va.a,&va.b); va.num=k++; q[va.a].push(va); } else { scanf("%d",&g); if(!q[g].empty()) { vb=q[g].top(); q[g].pop(); printf("%d\n",vb.num); } else { printf("EMPTY\n"); } } } } }
相关文章推荐
- git 查看单个文件的历史
- MyEclipse设置Java代码注释模板
- DB2问题诊断与解决: 一个由于历史文件过大,导致LOAD慢的问题
- UVa 821 - Page Hopping
- 读取单条json数据代码
- 安全测试之禁止页面缓存和文件上传校验
- Android RecyclerView——总结自DavidSmith的视频
- 怒刷BZOJ记录(二)1038~10xx
- poj 2456 Aggressive cows (二分+贪心思想)
- Ambari Metrics介绍
- 过年胖三斤
- xcode常用快捷键
- hive函数总结-日期函数
- Windows自带的磁盘填充命令
- 谷歌的HTML / CSS规范指南
- 使用Wireshark捕捉USB通信数据
- iOS开发之网络编程--使用NSURLConnection实现文件上传
- 【 bzoj 1444 】 [Jsoi2009]有趣的游戏 - AC自动机+矩阵乘法
- SecureCRT 常用技巧
- SwipeRefreshLayout的升级版RefreshLayout