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. java面向对象的三大特性——多态

    多态 所谓多态就是指程序中定义的引用变量所指向的具体类型和通过该引用变量发出的方法调用在编程时并不确定,而是在程序运行期间才确定,即一个引用变量倒底会指向哪个类的实例对象,该引用变量发出的方法调用到底 ...

  2. Linux指令--watch,at

    watch是一个非常实用的命令,基本所有的Linux发行版都带有这个小工具,如同名字一样,watch可以帮你监测一个命令的运行结果,省得你一遍遍的手动运行.在Linux下,watch是周期性的执行下个 ...

  3. c# 基础任务1

    1.winform系统全局异常布局处理. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);   ...

  4. 重置CentOS 7的Root密码

    centos7与centos6有很多修改,不一样了,打算写几篇关于日常用到的改动 修改root密码 centos7的用户模式跟6有所不同 1 - 在启动grub菜单,选择编辑选项启动 2 - 按键盘e ...

  5. redis 简易监控的几种方法

    简介 针对Redis 实现性能监控的几种方法 一.使用info命令 命令说明 127.0.0.1:6380> info # Server redis_version:3.2.11 redis_g ...

  6. VS工程中的Windows.h

    才发现这个Windows.h是有些奥秘的,不是随便引用就可以的. 1,C++工程,头文件引用要讲求一定顺序.如果cpp文件先引用a.h,再引用b.h,则后者自动包含a.h.这一点很重要. 2,Wind ...

  7. 使用命令行生成jar包

    测试用类 public class Hello { public static void main(String[] args) { System.out.println("hello wo ...

  8. python小白之路

    阅读目录: 第一章:计算机基础 计算机硬件.操作系统.网络协议 第二章:python基础 初识python.常量变量.输入输出运算符.条件与循环语句.数字与字符串.列表与字典.元组与集合.阶段小测.字 ...

  9. MySQL修改密码的三种方法

      MySQL修改密码的三种方法 1.方法1: 2.方法2: 3.方法3:        

  10. POJ1509 Glass Beads [后缀自动机]

    题意: 给一个字符串S,每次可以将它的第一个字符移到最后面,求这样能得到的字典序最小的字符串.输出开始下标 练习SAM第一题! SS构造SAM,然后从开始尽量走最小走n步就可以啦 什么?开始位置?!R ...