PAT 甲级 1017 Queueing at Bank
发布日期:2021-07-01 03:08:52 浏览次数:2 分类:技术文章

本文共 2425 字,大约阅读时间需要 8 分钟。

1017 Queueing at Bank (25 point(s))

Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow line, until it is his/her turn to be served and there is a window available. It is assumed that no window can be occupied by a single customer for more than 1 hour.

Now given the arriving time T and the processing time P of each customer, you are supposed to tell the average waiting time of all the customers.

Input Specification:

Each input file contains one test case. For each case, the first line contains 2 numbers: N (≤10​4​​) - the total number of customers, and K (≤100) - the number of windows. Then N lines follow, each contains 2 times: HH:MM:SS - the arriving time, and P - the processing time in minutes of a customer. Here HH is in the range [00, 23], MM and SS are both in [00, 59]. It is assumed that no two customers arrives at the same time.

Notice that the bank opens from 08:00 to 17:00. Anyone arrives early will have to wait in line till 08:00, and anyone comes too late (at or after 17:00:01) will not be served nor counted into the average.

Output Specification:

For each test case, print in one line the average waiting time of all the customers, in minutes and accurate up to 1 decimal place.

Sample Input:

7 307:55:00 1617:00:01 207:59:59 1508:01:00 6008:00:00 3008:00:02 208:03:00 10

Sample Output:

8.2

Experiential Summing-up

This question is 's simplified version. When a time with HH:mm:ss format convert into a integer, and notice the maximum time of sever not more than 60 minutes. This question will become so easy~~

 (The purpose of using English to portray my solution is that to exercise the ability of my expression of English and accommodate PAT advanced level's style.We can make progress together by reading and comprehending it. Please forgive my basic grammar's and word's error. Of course, I would appreciated it if you can point out my grammar's and word's error in comment section.( •̀∀•́ ) Furthermore, Big Lao please don't laugh at me because I just a English beginner settle for CET6    _(:з」∠)_  )

Accepted Code

#include 
#include
#include
using namespace std;const int INF=0x3fffffff;int k;struct customer{ int arrive,serve;};bool cmp(customer a,customer b){ return a.arrive
cus; double ans=0; for(int i=0;i

 

转载地址:https://meteorrain.blog.csdn.net/article/details/86560218 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:PAT 甲级 1018 Public Bike Management
下一篇:PAT 甲级 1016 Phone Bills

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2024年04月14日 03时31分05秒