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. httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName

    问题原因: httpd服务配置文件,并没有设置解析根地址,无法可靠地确定服务器的完全合格的域名 如何解决? httpd的配置文件放在 /etc/httpd/conf/目录下,去掉ServerName注 ...

  2. scrapy_css

    css选择器标准格式:reponse.css(css选择器::获取值) css选择器有哪些? *            选择所有节点 #id         选择id的节点 .container    ...

  3. Jquery实现选项卡效果

    <script type="text/javascript"> $(document).ready(function(){ $('.ct:gt(0)').hide(); ...

  4. android 软键盘的使用

    AndroidManifest.xml文件中界面对应的<activity>里加入android:windowSoftInputMode="adjustPan"   键盘 ...

  5. Request和Response

    1 简介 web服务器收到客户端的http请求,会针对每一个请求,分别创建一个用于代表请求的request对象和代表响应的response对象. request和response对象既然代表请求和响应 ...

  6. Python-常用第三方库

    python常用框架及第三方库(转载) 一.Web框架 1.Django: 开源web开发框架,它鼓励快速开发,并遵循MVC设计,比较庞大,开发周期短.Django的文档最完善.市场占有率最高.招聘职 ...

  7. 日历插件——laydate.js

    laydate是一款很好用的日历控件,兼容了包括IE6在内的所有主流浏览器,默认有三种皮肤,如需其它皮肤可去官网下载http://www.layui.com/laydate/  一.核心方法:layd ...

  8. 提取位于<title>...</title>内的文本标题内容

    #vim title.txt <title>nhlinkin</title> # cat title.txt  | sed 's:.*<title>\([^< ...

  9. 最大流模版 dinic

    朴素dinic+多路增广 #include <iostream> #include <cstdio> #include <cstring> #include < ...

  10. BZOJ 2329: [HNOI2011]括号修复 [splay 括号]

    题目描述 一个合法的括号序列是这样定义的: 空串是合法的. 如果字符串 S 是合法的,则(S)也是合法的. 如果字符串 A 和 B 是合法的,则 AB 也是合法的. 现在给你一个长度为 N 的由‘(' ...