简单模拟题。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
using namespace std; struct X
{
int st;
int len;
int en;
}p[];
queue<int>Q[];
int n,m,k,s; bool check()
{
for(int i=;i<=n;i++)
if(!Q[i].empty()) return ;
return ;
} int main()
{
scanf("%d%d%d%d",&n,&m,&k,&s);
for(int i=;i<=k;i++) scanf("%d",&p[i].len);
int pos;
for(pos=;pos<=min(k,n);pos++) { p[pos].st=; Q[pos].push(pos); }
for(;pos<=min(n*m,k);pos++)
{
int id=pos%n; if(id==) id=n;
Q[id].push(pos);
}
while()
{
if(check()==) break;
int Min=;
for(int i=;i<=n;i++)
{
if(Q[i].empty()) continue;
int id=Q[i].front();
Min=min(Min,p[id].st+p[id].len);
} for(int i=;i<=n;i++)
{
if(Q[i].empty()) continue;
int id=Q[i].front();
if(p[id].st+p[id].len==Min)
{
p[id].en=p[id].st+p[id].len;
Q[i].pop();
if(pos<=k) Q[i].push(pos++);
if(!Q[i].empty()) p[Q[i].front()].st=p[id].en;
}
}
}
for(int i=;i<=s;i++)
{
int id; scanf("%d",&id);
if(p[id].st/>=) printf("Sorry\n");
else printf("%02d:%02d\n",p[id].en/,p[id].en%);
}
return ;
}

PAT (Advanced Level) 1014. Waiting in Line (30)的更多相关文章

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

  2. 【PAT甲级】1014 Waiting in Line (30 分)(队列维护)

    题面: 输入四个正整数N,M,K,Q(N<=20,M<=10,K,Q<=1000),N为银行窗口数量,M为黄线内最大人数,K为需要服务的人数,Q为查询次数.输入K个正整数,分别代表每 ...

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

  5. 【PAT Advanced Level】1014. Waiting in Line (30)

    简单模拟题,注意读懂题意就行 #include <iostream> #include <queue> using namespace std; #define CUSTOME ...

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

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

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

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

  8. PAT 1014 Waiting in Line (30分) 一个简单的思路

    这题写了有一点时间,最开始想着优化一下时间,用优先队列去做,但是发现有锅,因为忽略了队的长度. 然后思考过后,觉得用时间线来模拟最好做,先把窗口前的队列填满,这样保证了队列的长度是统一的,这样的话如果 ...

  9. 1014. Waiting in Line (30)

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

随机推荐

  1. document.createDocumentFragment 方法

    基本概念 document.createDocumentFragment 方法会创建一个 DocumentFragment 对象,该对象是一个存在于 DOM 树之外的 DOM 节点.它有一个非常有用的 ...

  2. git 更新分支

    git branch  本地分支 git branch test 创建分支 git pull origin fastboot 更新到最新版本 git branch -a  查看所有的分支,包括本地的和 ...

  3. 封装sdk API 应用

    1 #include "QWinApp.h" 2 #include "QGlobal.h" 3 int WINAPI _tWinMain(HINSTANCE h ...

  4. oracle恢复一个数据表的方法

    今天提交给客户方一个sql脚本去跟新历史数据,结果客户那边的部署人员犯了一个错误,直接拿系统账号去部署,结果第一段代码没有执行成功,结果第二段代码却执行成功了,并且已经提交了的,....由于事前没有备 ...

  5. Net Protocol Related

    Data used to deliver through net should be encapsulated. General encapsulation include 4 layer of he ...

  6. libmysql.dll 找不到

    在用C#开发的时候,需要连接MySQL  ,系统提示  libmysql.dll 找不到模块. 我们可以找到 MySQL安装文件夹下的 C:\Program Files\MySQL\MySQL Ser ...

  7. Android 使用存放在存assets文件夹下的SQLite数据库

    因为这次的项目需要自带数据,所以就就把数据都放到一个SQLite的数据库文件中了,之后把该文件放到了assets文件夹下面.一开始打算每次都从assets文件夹下面把该文件夹拷贝到手机的SD卡或者手机 ...

  8. Android中Edittext的属性

    //此为转载别人的,挺不错的 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: 把该EditText设为:android:password="true"  ...

  9. 使用HttpUtils 上传视频文件

    private void shangchuan(){                 //文件的路径        //File file=new File(path);        File fi ...

  10. HDU 1269 迷宫城堡 tarjan算法求强连通分量

    基础模板题,应用tarjan算法求有向图的强连通分量,tarjan在此处的实现方法为:使用栈储存已经访问过的点,当访问的点离开dfs的时候,判断这个点的low值是否等于它的出生日期dfn值,如果相等, ...