Suppose a bank has N windows open for service.

一个银行有N个服务的窗口

There is a yellow line in front of the windows which devides the waiting area into two parts.

在每个窗口前面都一根黄线用来划分等待区的两个部分

The rules for the customers to wait in line are:

对于顾客来说等待线的规则是这样的

  • The space inside the yellow line in front of each window is enough to contain a line with M customers.

在每个窗口前面的黄线以内能够包含M个顾客

Hence when all the N lines are full, all the customers after (and including) the (NM+1)st one will have to wait in a line behind the yellow line.

因此,当所有N条线,所有的顾客中第N*M+1位顾客必须在黄线后等待

  • Each customer will choose the shortest line to wait in when crossing the yellow line.

当越过黄线之后,每个顾客将会选择最短的队伍去等待。

If there are two or more lines with the same length, the customer will always choose the window with the smallest number.

如果有两个或者更多的同样长度的队伍,顾客会总是会选择更小编号的队伍。

  • Customer[i] will take T[i] minutes to have his/her transaction processed.

顾客i将会花费Ti分钟处理自己的交易流程

  • The first N customers are assumed to be served at 8:00am.

前面N个顾客假定从早上8点开始被服务

Now given the processing time of each customer, you are supposed to tell the exact time at which a customer has his/her business done.

现在给出每个顾客的交易时间,要求你求出每个顾客完成业务的准确时间

For example, suppose that a bank has 2 windows and each window may have 2 custmers waiting inside the yellow line.

例如,一个银行有两个窗口,每个一个窗口能有两个顾客等在黄线内

There are 5 customers waiting with transactions taking 1, 2, 6, 4 and 3 minutes, respectively.

现在我5位顾客,花费的时间分别是12643

At 08:00 in the morning, customer1 is served at window1 while customer2 is served at window2.

在早上8点,顾客1在窗口1,顾客2在窗口2

Customer3 will wait in front of window1 and customer4 will wait in front of window2.

顾客3等在窗口1,顾客4等在窗口2

Customer5 will wait behind the yellow line.

顾客5等在黄线后

At 08:01, customer1 is done and customer5 enters the line in front of window1 since that line seems shorter now.

8点01分,顾客1完成了,顾客5进入线内,到了队伍最短的窗口1

Customer2 will leave at 08:02, customer4 at 08:06, customer3 at 08:07, and finally customer5 at 08:10.

顾客2,在8点02离开,顾客4.。。。。。。。

Input

Each input file contains one test case. Each case starts with a line containing 4 positive integers: N (<=20, number of windows), M (<=10, the maximum capacity of each line inside the yellow line), K (<=1000, number of customers), and Q (<=1000, number of customer queries).

每个输入文件包含一个测试用例,每个测试用例由4个整数开始,N, M, K, Q

The next line contains K positive integers, which are the processing time of the K customers.

下面K个正整数表示K顾客花费的时间

The last line contains Q positive integers, which represent the customers who are asking about the time they can have their transactions done. The customers are numbered from 1 to K.

最后一行Q个整数,代表那些想要询问他们想要询问他们到底花费了多少时间的人。顾客的编号从1到K

Output

For each of the Q customers, print in one line the time at which his/her transaction is finished, in the format HH:MM where HH is in [08, 17] and MM is in [00, 59]. Note that since the bank is closed everyday after 17:00, for those customers who cannot be served before 17:00, you must output "Sorry" instead.

对于q个顾客,打印一行时间,他完成的时间,格式是HH:MM,HH是08-17,MM是00-59。记住银行每天17:00关门,对于那些不能再17:00完成的业务的,你需要输出soory

Sample Input

2 2 7 5
1 2 6 4 3 534 2
3 4 5 6 7

Sample Output

08:07
08:06
08:10
17:00
Sorry
题目的意思已经很明显了,银行排队,已经很明显了,数据结构用队列就行了,每个窗口一个队列,然后到时间了完成了出队,然入队,主要考验模拟时的逻辑能力。用queue会简单一些。
 

PAT1014的更多相关文章

  1. PAT1014——福尔摩斯的约会

    大侦探福尔摩斯接到一张奇怪的字条:“我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm”.大侦探很快就明白了,字条 ...

  2. pat1014. Waiting in Line (30)

    1014. Waiting in Line (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Suppo ...

  3. 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 ...

  4. PAT甲级1014. Waiting in Line

    PAT甲级1014. Waiting in Line 题意: 假设银行有N个窗口可以开放服务.窗前有一条黄线,将等候区分为两部分.客户要排队的规则是: 每个窗口前面的黄线内的空间足以包含与M个客户的一 ...

  5. PAT 1011-1020 题解

    早期部分代码用 Java 实现.由于 PAT 虽然支持各种语言,但只有 C/C++标程来限定时间,许多题目用 Java 读入数据就已经超时,后来转投 C/C++.浏览全部代码:请戳 本文谨代表个人思路 ...

随机推荐

  1. ****Curling 2.0(深搜+回溯)

    Curling 2.0 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total ...

  2. C#第八天

    ArrayList ArrayList list=new ArrayList(): list.Add()           //添加单个元素 list.AddRange()   //添加集合元素 l ...

  3. 12C expdp issue

    issue 1: 使用expdp时遭遇ora-31650 D:\oracle\diag\rdbms \trace>expdp \"/ as sysdba\"  schemas ...

  4. 终于下决心在cnblogs上安家了,^_^

    以前在这个地方学到了很多东西,希望在这里安家以后,自己也可以有很多成长. mark一下,~~

  5. Sping3.0版本+Quartz完成定时任务

    ----------------------不使用注解在XML中配置完成定时任务---------------------- 1.需要导入的jar包 2.编写我们的定时任务的完成类 3.在Spring ...

  6. LYF模板连接.txt

    在解决方案里创建了一个新建网站,在其右键下添加一个模板后,准备使用模板的,在添加新建项里突然没有“使用模板页的web窗体”,顿时感觉悲剧... 解决方法:模板页代码---LYFMaterPage.Ma ...

  7. iOS不可变字符串的所有操作

    可以直接复制代码即可运行看看结果,方便理解 //NSString //OC字符串不能用printf输出 //但是遗憾的是OC没有一个从终端读取数据的方式,需要使用scanf读取C字符串然后转换成OC的 ...

  8. 《C++ Primer》之面向对象编程(二)

    构造函数和复制控制 每个派生类对象由派生类中定义的(非 static)成员加上一个或多个基类子对象构成,当我们构造.复制.赋值和撤销一个派生类对象时,也会构造.复制.赋值和撤销这些基类子对象. 构造函 ...

  9. hdu_5795_A Simple Nim(打表找规律的博弈)

    题目链接:hdu_5795_A Simple Nim 题意: 有N堆石子,你可以取每堆的1-m个,也可以将这堆石子分成3堆,问你先手输还是赢 题解: 打表找规律可得: sg[0]=0 当x=8k+7时 ...

  10. 矩阵快速幂——将运算推广到矩阵上HDU 1575

    /* 本题的思路比较简单,就是将递推公式写出来,然后表达成为一个矩阵的形式 最后通过计算就可以得到一个符合题目要求的矩阵, 然后就是将矩阵上面所有的对角线元素相加 得到的结果即为所求的目标 */ #i ...