PAT (Advanced Level) 1017. Queueing at Bank (25)
简单模拟。
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
using namespace std; struct X
{
long long hh,mm,ss;
long long len;
long long st,ml;
}s[+];
int n,k;
long long win[]; bool cmp(const X&a,const X&b)
{
return a.st<b.st;
} int main()
{
scanf("%d%d",&n,&k);
for(int i=;i<=n;i++)
{
scanf("%lld:%lld:%lld %lld",&s[i].hh,&s[i].mm,&s[i].ss,&s[i].len);
s[i].st=s[i].hh**+s[i].mm*+s[i].ss;
s[i].len=s[i].len*;
}
sort(s+,s++n,cmp);
for(int i=;i<=k;i++) win[i]=**;
int i;
int cnt=;
for(int i=;i<=n;i++)
{
long long Min=;
if(s[i].st>**) break;
cnt++;
for(int j=;j<=k;j++) Min=min(Min,win[j]);
for(int j=;j<=k;j++)
{
if(win[j]==Min)
{
s[i].ml=max(win[j],s[i].st);
win[j]=s[i].ml+s[i].len;
break;
}
}
}
long long sum=;
for(int k=;k<=cnt;k++) sum=sum+s[k].ml-s[k].st;
if(cnt!=) printf("%.1f\n",1.0*sum//cnt);
else printf("0.0\n");
return ;
}
PAT (Advanced Level) 1017. Queueing at Bank (25)的更多相关文章
- 【PAT甲级】1017 Queueing at Bank (25 分)
题意: 输入两个正整数N,K(N<=10000,k<=100)分别表示用户的数量以及银行柜台的数量,接下来N行输入一个字符串(格式为HH:MM:SS)和一个正整数,分别表示一位用户到达银行 ...
- 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 ...
- 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 ...
- PAT甲题题解-1017. Queueing at Bank (25)-模拟
有n个客户和k个窗口,给出n个客户的到达时间和需要的时长有空闲的窗口就去办理,没有的话就需要等待,求客户的平均时长.如果在8点前来的,就需要等到8点.如果17点以后来的,则不会被服务,无需考虑. 按客 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- PAT (Advanced Level) 1113. Integer Set Partition (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
随机推荐
- ueditor浏览器 无法上传文件.问题
dll也都引用了 路径绝对tmd没问题 最后 我一点一点的调试发现了问题 草tmd百度程序员 */UE.ajax = function() { //创建一个ajaxRequest对象 var fnSt ...
- Linux 添加ssh 公钥访问
登陆被管理的服务器,进入需要远程登陆的用户目录,把公钥放到用户目录的 .ssh 这个目录下(如果目录不存在,需要创建~/.ssh目录,并把目录权限设置为700),把公钥改名为authorized_ke ...
- Petit FatFs
FatFs is a generic FAT/exFAT file system module for small embedded systems. The FatFs module is writ ...
- sql查询百分号的方法
select * from [tablename] where [col] like '%100/%%' escape '/'
- adodb.stream对象的方法/属性
Cancel 方法 使用方法如下 Object.Cancel 说明:取消执行挂起的异步 Execute 或 Open 方法的调用.Close 方法 使用方法 ...
- Spring Boot 系列教程1-HelloWorld
入门 如果你用过Spring JavaConfig的话,会发现虽然没有了xml配置的繁琐,但是使用各种注解导入也是很大的坑, 然后在使用一下Spring Boot,你会有一缕清风拂过的感觉, 真是爽的 ...
- Hibernate 系列教程10-组成关系
组成关系 在一个员工模型里面需要存入 员工公司所在地址的城市,街道 员工籍贯所在的城市,街道, 此时可以抽取城市,街道变成一个模型即是组成关系 Employee public class Employ ...
- AI 人工智能 探索 (九)
链接:http://pan.baidu.com/s/1c0AM3g0 密码:uccw 今天补充 创建物体 移动物体 ,当点击创建后 ,会出来一个 上图的 ui,他跟随 物体,当你把物体拖动到 指定的地 ...
- Nape 获取碰撞点加特效
package { import nape.phys.Body; import nape.shape.Shape; import nape.shape.Circle; import flash.dis ...
- java String不可变对象,但StringBuffer是可变对象
什么是不可变对象? 众所周知, 在Java中, String类是不可变的.那么到底什么是不可变的对象呢? 可以这样认为:如果一个对象,在它创建完成之后,不能再改变它的状态,那么这个对象就是不可变的.不 ...