HDU 1873 看病要排队
HDU 排队
2023-09-11 14:20:43 时间
优先队列,水题。
三个医生。相应三个优先队列就能够了。
多组数据要初始化优先队列
#include<cstdio> #include<cstring> #include<string> #include<queue> #include<algorithm> #include<map> #include<stack> #include<iostream> #include<list> #include<set> #include<vector> #include<cmath> #define INF 0x7fffffff #define eps 1e-8 #define LL long long #define PI 3.141592654 #define CLR(a,b) memset(a,b,sizeof(a)) #define FOR(i,a,b) for(int i=a;i<b;i++) #define FOR0(i,a,b) for(int i=a;i>=b;i--) #define pb push_back #define debug puts("==fuck==") #define acfun std::ios::sync_with_stdio(false) #define SIZE 20+10 using namespace std; struct lx { int value; int ID; friend bool operator <( lx a,lx b) { if(a.value==b.value) return a.ID>b.ID; return a.value<b.value; } }; int main() { int t; priority_queue<lx> q[4]; int Id=1; while(scanf("%d",&t)!=EOF) { char head[11]; scanf("%s",head); if(strcmp(head,"OUT")==0) { int value; scanf("%d",&value); if(q[value].empty()) puts("EMPTY"); else { lx now; now=q[value].top(); q[value].pop(); printf("%d\n",now.ID); } } else if(strcmp(head,"IN")==0) { int value; lx now; scanf("%d%d",&value,&now.value); now.ID=Id++; q[value].push(now); } t--; if(t==0) { FOR(i,1,4) { while(!q[i].empty()) q[i].pop(); } Id=1; } } }
相关文章
- HDU 3247 Resource Archiver (AC自己主动机 + BFS + 状态压缩DP)
- HDU 2686 Matrix(最大费用流)
- hdu 4786 Fibonacci Tree
- HDU 3036 Escape 网格图多人逃生 网络流||二分匹配 建图技巧
- HDU 3068 最长回文 Manacher算法
- HDU 4825 Xor Sum
- hdu 2059 龟兔赛跑 (dp)
- HDU 3639 Hawk-and-Chicken(良好的沟通)
- hdu - 5045 - Contest(国家压缩dp)
- HDU 3988 Harry Potter and the Hide Story(数论-整数和素数)