【PAT Advanced Level】1014. Waiting in Line (30)
来源:互联网 发布:企鹅ico软件图标 编辑:程序博客网 时间:2024/06/06 12:36
简单模拟题,注意读懂题意就行
#include <iostream>#include <queue>using namespace std;#define CUSTOMER_MAX 1000+1#define INF 0x6fffffff #ifndef LOCAL//#define LOCAL#endif LOCALint n; // number of windows <=20int m ;// queue capacity <=10int k; // customers <=1000int q; // query times <=1000int ProcessTime[CUSTOMER_MAX]; // queue<int> que[20];queue<int >Wait[20];int currTime = 0;int LeaveTime[CUSTOMER_MAX];int Timebase[20] = {0};int main(){#ifdef LOCALfreopen("input.txt","r",stdin);freopen("output.txt","w",stdout);#endifcin>>n>>m>>k>>q;for(int i=0;i<k;i++){cin>>ProcessTime[i];}int index;int top = 0;for(int i = 0;i<2*k;i++) {int min_len = m;if(top !=k) // if there are any customer not in line{for(int j=0;j<n;j++) {if(min_len > que[j].size() ){min_len = que[j].size();index = j;}}}if(min_len != m) // find minimum queue {que[index].push(top);Wait[index].push(ProcessTime[top]);top++;}else // no queue available or no customer not in line, then customer pop {long min_wait = INF;bool empty = true;for(int j=0;j<n;j++){if(Wait[j].empty()) continue;if(min_wait > Timebase[j]+Wait[j].front()) // find current minimum wait time{min_wait = Timebase[j]+Wait[j].front();index = j;empty = false;}}if(empty) break;Timebase[index] += Wait[index].front();LeaveTime[que[index].front()] = Timebase[index];que[index].pop();Wait[index].pop();}}//60*9int qq;for(int i=0;i<q;i++){cin>>qq;qq--;if(LeaveTime[qq]-ProcessTime[qq]<60*9){int hour = LeaveTime[qq]/60;int second = LeaveTime[qq]%60;printf("%02d:%02d\n",8+hour,second); }elseprintf("Sorry\n");}#ifdef LOCALsystem("PASUE");#endif LOCALreturn 0;}
- 【PAT Advanced Level】1014. Waiting in Line (30)
- PAT (Advanced Level) Practise 1014. Waiting in Line (30)
- PAT (Advanced Level) 1014. Waiting in Line (30) 银行排队
- 浙大 PAT Advanced level 1014. Waiting in Line (30)
- 【PAT】【Advanced Level】1014. Waiting in Line (30)
- PAT (Advanced) 1014. Waiting in Line (30)
- PAT (Advanced) 1014. Waiting in Line (30)
- 1014. Waiting in Line @ PAT (Advanced Level) Practise
- [PAT (Advanced Level) ]1014.Waiting in Line 解题文档
- PAT (Advanced Level) Practise 1014 Waiting in Line (30)
- PAT (Advanced Level) Practise 1014 Waiting in Line (30)
- 1014. Waiting in Line (30)——PAT (Advanced Level) Practise
- Pat(Advanced Level)Practice--1014(Waiting in Line)
- [ZJU.PAT] 1014. Waiting in Line (30)
- 1014. Waiting in Line (30)-PAT
- pat 1014. Waiting in Line (30)
- PAT 1014. Waiting in Line (30)
- PAT A 1014. Waiting in Line (30)
- Havel-Hakimi定理(判断一个序列是否可图) UVA 10720
- ACM->CF 358A
- POJ 2462 / HDU 1154 Cutting a Polygon
- initramfs
- 如何判断通过ShellExecute执行的应用程序已经执行完毕?
- 【PAT Advanced Level】1014. Waiting in Line (30)
- USACO Friday the Thirteenth
- i.MX53 电容触摸屏驱动 - FT5x06
- Java接口
- 工作小结python和cpp通过json互通
- 11# 2013-10-31
- select函数
- 分段函数项目
- date(): It is not safe to rely on the system’s timezone settings.