pat1014 Waiting in line

原创 2016年08月29日 16:41:11
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<stdlib.h>
using namespace std;
struct cus{
	int pt;
	int st;
	int ct;
};
int main(void){
	int n,m,k,q,i,j;
	cin >> n >> m >> k >> q;
	cus cu[1000];
	int cusq[1000];
	for(i = 0;i < k;++i)
	cin >> cu[i].pt;
	for(i = 0;i < q;++i)
	cin >> cusq[i];
	queue<cus>win[20];
	int wint[20],cust[20];
	for(i = 0;i < n;++i)
		wint[i] = 0;
	for(i = 0;i < m;++i){
		for(j = 0;j < n;++j){
			if(i > 0)
			cust[j] += cu[n*(i-1)+j].pt;
			else
				cust[j] = 0;
			cu[i*n+j].st = cust[j];
			cu[i*n+j].ct = cu[i*n+j].pt + cu[i*n+j].st;
			win[j].push(cu[i*n+j]);
			wint[j] += cu[i*n+j].pt;
		}
	}
	int min;
	int key;
	for(j = n*m;j < k;++j){
		min = win[0].front().ct;
		key = 0;
	for(i = 0;i < n;++i){
		if(win[i].front().ct < min){
			min = win[i].front().ct;
			key = i;
		}
	}
		cu[j].st = win[key].front().st + wint[key];
		//cout << win[key].front().st << wint[key] << endl;
		cu[j].ct = cu[j].pt + cu[j].st;
		wint[key] += cu[j].pt;
		wint[key] -= win[key].front().pt;
		win[key].pop();
		win[key].push(cu[j]);
	}
	for(i = 0;i < q;++i){
		if(cu[cusq[i]-1].st < 9*60)
		printf("%.2d:%.2d\n",8+cu[cusq[i]-1].ct/60,cu[cusq[i]-1].ct%60);
		else
			cout << "Sorry" << endl;
	}
	system("pause");
	return 0;
}

PAT 1014 Waiting in Line(模拟+队列操作)

题目https://www.patest.cn/contests/pat-a-practise/1014 银行前台处理客户的过程如下,有n个窗口,每个窗口前的队伍可以排m个人,其余人在黄线外等待;...

PAT_1014: Waiting in Line

Suppose a bank has N windows open for service. There is a yellow line in front of the windows which ...

PAT 1014 Waiting in Line (模拟)

PAT 1014 Waiting in Line (模拟)
  • Dacc123
  • Dacc123
  • 2016年05月30日 17:37
  • 256

Pat(Advanced Level)Practice--1014(Waiting in Line)

Pat1014代码 题目描述: Suppose a bank has N windows open for service. There is a yellow line in front of...

pat 1014. Waiting in Line

Suppose a bank has N windows open for service. There is a yellow line in front of the windows which ...

PAT 甲级 1014 Waiting in Line (30)

PAT这道题是一道模拟题 https://www.patest.cn/contests/pat-a-practise/1014 其实逻辑正确,并且注意到几个陷进就能把这道题做出来。 下面说说我在做这道...

PAT (Advanced Level) Practise 1014 Waiting in Line (30)

1014. Waiting in Line (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 ...

pat1014Waiting in Line (30)

题意分析: (1)本题模拟银行排队,逻辑上不难,操作起来有点麻烦。银行来了K个客户,银行有N个窗口,每个窗口前有M个位置排队,客户选择最短的队伍排,根据每个客户的序号和服务时间来确定最后客户离开银行的...

PAT 甲级 1014. Waiting in Line

原题传送门 队列queue的应用 判断是否出队的方法:模拟时间流动,依次检查各个窗口队列 时间的处理:先用十进制,最后输出时间格式 #include #include using namespace ...

PAT_A 1014. Waiting in Line (30)

1014. Waiting in Line (30)Suppose a bank has N windows open for service. There is a yellow line in f...
  • scylhy
  • scylhy
  • 2016年12月03日 13:50
  • 152
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:pat1014 Waiting in line
举报原因:
原因补充:

(最多只允许输入30个字)