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 (<=10000) - 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 3
07:55:00 16
17:00:01 2
07:59:59 15
08:01:00 60
08:00:00 30
08:00:02 2
08:03:00 10

Sample Output:

8.2

 #include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
struct cus
{
int arrive_time,cost;
};
struct win
{
win():win_time(**){}
int win_time;
}; win wins[]; bool cmparrive(cus a,cus b)
{
return a.arrive_time < b.arrive_time;
}
int main()
{
int n,w_num,hh,mm,ss;
cus ctem;
vector<cus> vv;
scanf("%d%d",&n,&w_num);
for(int i = ;i < n;++i)
{
scanf("%d:%d:%d%d",&hh,&mm,&ss,&ctem.cost);
if(ctem.cost > )
ctem.cost = ;
ctem.cost *= ;
ctem.arrive_time = hh** + mm* + ss;
if(ctem.arrive_time <= * * )
vv.push_back(ctem);
}
sort(vv.begin(),vv.end(),cmparrive);
int cnt = ;
double sum = 0.0;
n = vv.size();
while(cnt < n)
{
int MIN = ;
int MINindex = -;
for(int i = ;i < w_num;++i)
{
if(MIN > wins[i].win_time)
{
MIN = wins[i].win_time;
MINindex = i;
}
}
if(MIN > vv[cnt].arrive_time)
{
sum += (MIN - vv[cnt].arrive_time);
wins[MINindex].win_time += vv[cnt].cost;
++cnt;
}
else
{
for(int i = ;i < w_num;++i)
{
if(vv[cnt].arrive_time >= wins[i].win_time)
{
MINindex = i;
break;
}
}
wins[MINindex].win_time = vv[cnt].arrive_time + vv[cnt].cost;
++ cnt;
}
}
if(n == )
printf("0.0\n");
else
printf("%.1lf\n",sum/60.0/n);
return ;
}
												

1017. Queueing at Bank (25)的更多相关文章

  1. PAT 甲级 1017 Queueing at Bank (25 分)(模拟题,有点思维小技巧,第二次做才理清思路)

    1017 Queueing at Bank (25 分)   Suppose a bank has K windows open for service. There is a yellow line ...

  2. 1017. Queueing at Bank (25) - priority_queuet

    题目如下: Suppose a bank has K windows open for service. There is a yellow line in front of the windows ...

  3. 1017 Queueing at Bank (25)(25 point(s))

    problem Suppose a bank has K windows open for service. There is a yellow line in front of the window ...

  4. PAT 1017 Queueing at Bank (25) (坑题)

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

  5. 1017 Queueing at Bank (25 分)

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

  6. PAT (Advanced Level) 1017. Queueing at Bank (25)

    简单模拟. #include<iostream> #include<cstring> #include<cmath> #include<algorithm&g ...

  7. PAT甲题题解-1017. Queueing at Bank (25)-模拟

    有n个客户和k个窗口,给出n个客户的到达时间和需要的时长有空闲的窗口就去办理,没有的话就需要等待,求客户的平均时长.如果在8点前来的,就需要等到8点.如果17点以后来的,则不会被服务,无需考虑. 按客 ...

  8. 【PAT甲级】1017 Queueing at Bank (25 分)

    题意: 输入两个正整数N,K(N<=10000,k<=100)分别表示用户的数量以及银行柜台的数量,接下来N行输入一个字符串(格式为HH:MM:SS)和一个正整数,分别表示一位用户到达银行 ...

  9. PAT 1017 Queueing at Bank[一般]

    1017 Queueing at Bank (25)(25 分)提问 Suppose a bank has K windows open for service. There is a yellow ...

随机推荐

  1. css 所有选择器

    选择器 例子 例子描述 CSS .class .intro 选择 class="intro" 的所有元素. 1 #id #firstname 选择 id="firstna ...

  2. PF防火墙

    PF防火墙 点击认领       PF防火墙 ( 全称:Packet Filter ) 是 UNIX LIKE 系统上进行 TCP/IP 流量过滤和网络地址转换的软件系统.PF 同样也能提供 TCP/ ...

  3. Sharepoint中有关文件夹的操作

    1.GetItemsWithUniquePermissions根据返回数量和是否返回文件夹获取唯一权限的列表项集合 对于SharePoint对象模型中SPList的GetItemsWithUnique ...

  4. Table of Contents - Apache Commons

    Apache Commons 简述 CLI Usage of CLI Option Properties Codec 常见的编码解码 Compress Configuration2 Quick sta ...

  5. 【CSS3】---@font-face

  6. Mysql中查找并删除重复数据的方法

    (一)单个字段 1.查找表中多余的重复记录,根据(question_title)字段来判断 代码如下 复制代码 select * from questions where question_title ...

  7. C# Ajax 手机发送短信验证码 校验验证码 菜鸟级别实现方法

    1.Ajax请求处理页面: using System; using System.Collections.Generic; using System.Linq; using System.Web; u ...

  8. asp.net 下载Excel (数据流,不保存)--客户端

    效果图: 前端页面 <html> <head> <title>Test For Excel</title> <script src="j ...

  9. JAVA 模糊查询方法

    当我们需要开发一个方法用来查询数据库的时候,往往会遇到这样一个问题:就是不知道用户到底会输入什么条件,那么怎么样处理sql语句才能让我们开发的方法不管接受到什么样的条件都可以正常工作呢?这时where ...

  10. ie、IE兼容模式,提示SCRIPT1028: 缺少标识符、字符串或数字

    旧版ie下json最后一项是不允许有逗号的 为了更好的兼容各个浏览器,json最后的逗号最好不加