n个窗口就有n个队列,模拟这n个队列就可以了。需要注意的是,一个人在选择排队窗口的时候,他会选择排队人数最少的窗口,如果存在多个窗口排队的人数相同,那么他会选择编码最小的窗口。

  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.这句话的意思就是:对于那些不能再17:00之前开始服务的人,请输入"Sorry"。换句话说,就是那些能在五点钟之前开始服务及时服务结束时间超过五点也是可以的!!!所以在计算时,假设$f(i)$表示第$i$个用户结束服务的时间,$serv(i)$表示用户的服务时间,如果满足条件$f(i) - serv(i) \ge (17 - 8) \times 60$,则该客户不能完成服务!!

AC代码

 #include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn = + ;
int n, m, k, q;
int serv[maxn], done[maxn];
int line[][maxn], s[maxn], f[maxn]; int main() {
while(scanf("%d%d%d%d", &n, &m, &k, &q) == ) {
for(int i = ; i <= k; i++)
scanf("%d", &serv[i]);
for(int i = ; i <= n; i++) {
s[i] = f[i] = ;
done[i] = serv[i];
line[i][] = i;
}
for(int i = n+; i <= k; i++) {
bool full = ;
int cnt = m + , bet = ;
for(int j = ; j <= n; j++) {
if(f[j] - s[j] + < m) {
full = ;
if(f[j] - s[j] + < cnt) {
cnt = f[j] - s[j] + ;
bet = j;
}
}
}
if(full) {
int over_time = INF;
bet = ;
for(int j = ; j <= n; j++) {
int id = line[j][s[j]];
if(done[id] < over_time) {
bet = j;
over_time = done[id];
}
}
s[bet] += ;
}
f[bet] += ;
line[bet][f[bet]] = i;
done[i] = done[line[bet][f[bet]-]] + serv[i]; }
int qID;
for(int i = ; i < q; i++) {
scanf("%d", &qID);
if(done[qID] - serv[qID] >= (-)*)
printf("Sorry\n");
else
printf("%02d:%02d\n", done[qID]/+, done[qID]%);
}
}
return ;
}

如有不当之处欢迎指出!

1014. Waiting in Line (模拟)的更多相关文章

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

  2. PAT 1014 Waiting in Line (模拟)

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

  3. PAT 甲级 1014 Waiting in Line (30 分)(queue的使用,模拟题,有个大坑)

    1014 Waiting in Line (30 分)   Suppose a bank has N windows open for service. There is a yellow line ...

  4. PAT甲级1014. Waiting in Line

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

  5. 1014 Waiting in Line (30分)

    1014 Waiting in Line (30分)   Suppose a bank has N windows open for service. There is a yellow line i ...

  6. PAT A 1014. Waiting in Line (30)【队列模拟】

    题目:https://www.patest.cn/contests/pat-a-practise/1014 思路: 直接模拟类的题. 线内的各个窗口各为一个队,线外的为一个,按时间模拟出队.入队. 注 ...

  7. PTA (Advanced Level) 1014 Waiting in Line

    Waiting in Line Suppose a bank has N windows open for service. There is a yellow line in front of th ...

  8. PAT甲题题解-1014. Waiting in Line (30)-模拟,优先级队列

    题意:n个窗口,每个窗口可以排m人.有k为顾客需要办理业务,给出了每个客户的办理业务时间.银行在8点开始服务,如果窗口都排满了,客户就得在黄线外等候.如果有一个窗口用户服务结束,黄线外的客户就进来一个 ...

  9. 1014 Waiting in Line (30)(30 point(s))

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

随机推荐

  1. scrapy_随机user-agent

    什么是user-agent? 用户代理,服务器识别用户的操作系统,浏览器类型和渲染引擎,不同浏览器的user-agent是不同的 如何随机更改user-agent? 1. 在setting中添加use ...

  2. 数据访问(DAO)

    那些年,到处刮起了业务处理分层的大风,无论何时何地,都有某MVC框架.Spring管理的Service.以及iBatis和Hibernate等代表的DAO,SSH.SSI等成了标准.然而,我们仔细研究 ...

  3. maven(项目管理工具系列 maven 总结二)

    ♣maven是什么? ♣maven下载.安装 ♣了解maven仓库 ♣eclipse配置maven ♣创建maven项目 ♣把maven项目转化为web项目 1.maven是什么? Maven是一个项 ...

  4. CentOS之7与6的区别

    前言 centos7与6之间最大的差别就是初始化技术的不同,7采用的初始化技术是Systemd,并行的运行方式,除了这一点之外,服务启动.开机启动文件.网络命令方面等等,都说6有所不同.让我们先来了解 ...

  5. The mkdir Command

    The mkdir command is is used to create new directories. A directory, referred to as a folder in some ...

  6. [DeeplearningAI笔记]改善深层神经网络1.1_1.3深度学习使用层面_偏差/方差/欠拟合/过拟合/训练集/验证集/测试集

    觉得有用的话,欢迎一起讨论相互学习~Follow Me 1.1 训练/开发/测试集 对于一个数据集而言,可以将一个数据集分为三个部分,一部分作为训练集,一部分作为简单交叉验证集(dev)有时候也成为验 ...

  7. 基于SpringMVC+Mybatis搭建简单的前后台交互系统

    前面博文有一篇 名为基于tomcat+springMVC搭建基本的前后台交互系统(http://www.cnblogs.com/hunterCecil/p/6924935.html),例文中使用了Io ...

  8. Cookie简述

    1. Cookie是什么? Cookie(Cookies,浏览器缓存), 是指某些网站为了辨别用户身份.进行session跟踪而储存在用户本地终端上的数据(通常经过加密). 2. Cookie的作用: ...

  9. 手把手的SpringBoot教程,SpringBoot创建web项目(一)

    1.引子 大家好,在接下里的半个多小时,我会给大家详细的介绍SpringBoot的基本使用,相信学完这门课程以后,你会对SpringBoot有一个清晰的认识,并且能够运用这门比较新颖的技术开发一些小程 ...

  10. rsync推送和拉取

    rsync格式: # 拷贝本地文件.当SRC和DES路径信息都不包含有单个冒号":"分隔符时就启动这种工作模式.如:rsync -a /data /backup rsync [OP ...