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

原题传送门 队列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...

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)

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(模拟+队列操作)

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

PAT 1014. Waiting in Line (30)

题目:1014. Waiting in Line (30) 思路:            1.在黄线内,客户队列已定;            2.在黄线外,根据各窗口目前服务...

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 (模拟)

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 ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

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