标签:
简单模拟题。
#include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<map> #include<queue> using namespace std; struct X { int st; int len; int en; }p[1500]; queue<int>Q[25]; int n,m,k,s; bool check() { for(int i=1;i<=n;i++) if(!Q[i].empty()) return 1; return 0; } int main() { scanf("%d%d%d%d",&n,&m,&k,&s); for(int i=1;i<=k;i++) scanf("%d",&p[i].len); int pos; for(pos=1;pos<=min(k,n);pos++) { p[pos].st=480; Q[pos].push(pos); } for(;pos<=min(n*m,k);pos++) { int id=pos%n; if(id==0) id=n; Q[id].push(pos); } while(1) { if(check()==0) break; int Min=999999; for(int i=1;i<=n;i++) { if(Q[i].empty()) continue; int id=Q[i].front(); Min=min(Min,p[id].st+p[id].len); } for(int i=1;i<=n;i++) { if(Q[i].empty()) continue; int id=Q[i].front(); if(p[id].st+p[id].len==Min) { p[id].en=p[id].st+p[id].len; Q[i].pop(); if(pos<=k) Q[i].push(pos++); if(!Q[i].empty()) p[Q[i].front()].st=p[id].en; } } } for(int i=1;i<=s;i++) { int id; scanf("%d",&id); if(p[id].st/60>=17) printf("Sorry\n"); else printf("%02d:%02d\n",p[id].en/60,p[id].en%60); } return 0; }
PAT (Advanced Level) 1014. Waiting in Line (30)
标签:
原文地址:http://www.cnblogs.com/zufezzt/p/5497207.html