题目链接:uva 10588 - Queuing at the doctors
题目大意:公司安排职员去进行体检。一共有n个人,m个项目,给定每个职员到达医院的时间,以及需要体检的项目和顺序,每个项目检查一人需要消耗单位时间。每个项目的医生优先体检先到的职员,对于同时到的职员优先处理职员编号小的。求最后一个员工离开医院的时间。
解题思路:对每一个项目开一个优先队列,然后遍历时间,每次对时间满足进行体检,然后将人放到下一个这个人对应的下一个项目。
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int maxn = 1005;
struct item {
int ti, pos, id;
item (int ti = 0, int id = 0, int pos = 0) {
this->ti = ti;
this->id = id;
this->pos = pos;
}
bool operator < (const item& u) const {
return ti > u.ti || (ti == u.ti && id > u.id);
}
};
int N, M;
vector<int> g[maxn];
priority_queue<item> que[maxn];
void init () {
int t, k, x;
scanf("%d%d", &N, &M);
for (int i = 1; i <= N; i++) {
g[i].clear();
scanf("%d%d", &t, &k);
for (int j = 0; j < k; j++) {
scanf("%d", &x);
g[i].push_back(x);
}
que[g[i][0]].push(item(t, i, 0));
}
}
int solve () {
int ret = 0;
bool flag = true;
while (flag) {
flag = false;
for (int i = 1; i <= M; i++) {
if (que[i].empty())
continue;
flag = true;
item u = que[i].top();
if (u.ti > ret)
continue;
que[i].pop();
if (u.pos + 1 >= g[u.id].size())
continue;
int next = g[u.id][u.pos+1];
que[next].push(item(ret+1, u.id, u.pos+1));
}
ret++;
}
return ret - 1;
}
int main () {
int cas;
scanf("%d", &cas);
while (cas--) {
init();
printf("%d\n", solve());
}
return 0;
}
分享到:
相关推荐
Laravel开发-queuing 排队提供排队性能提高幅度4.2
Ajax-ola-queuing-system.zip,ola自动排队系统v1.2提交docsapp,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于创建动态网页,其中网页的小部分在不重新加载...
Clojure 排队示例 ...user=>(def server (clojure-queuing.web/-main)) 您的应用程序现在应该在上运行。 部署到 Heroku $ heroku create $ heroku addons:add cloudamqp $ git push heroku master
通过Redis分布式缓存数据库或RabbitMQ实现消息队列(MessageQueuing)
添加到队列将按顺序启动承诺 Promise 被它们承诺结果或拒绝的能力所束缚。 用法: 假设 '$q' 在注入器函数的参数中。 var deferedPromise = $q . defer ( ) ; var task = { success : function ( data ) { ...
排队集线器 适用于Python的多云队列中心
Oracle8i Application Developer’s Guide - Advanced Queuing Release 2 (8.1.6)
基于优先级的排队系统的事件驱动模拟 该项目为具有两类客户的排队网络实现了仿真。 网络中有两个队列。 假定队列容量是无限的,并且每...当低优先级客户离开队列1时,它以概率r12L进入队列2并以概率r11L返回队列1。 当
基于排队网络认知体系的驾驶员车辆跟驰模型研究,毕路拯,Liu Yili ,车辆跟驰控制是一种常见的驾驶活动。在认知体系框架下建模驾驶员的车辆跟驰控制有助于和驾驶相关的人因研究。 排队网络认知体系�
排队matlab代码MMmk排队模型 Matlab代码模拟M / M / m / k排队模型 只需更改代码中的m和k值即可模拟不同的排队模型。
Queuing analysis is one of the most important tools for those involved with computer and network analysis. It can be used to provide approximate answers to a host of questions, such as: · What ...
基于Web的银行预约和排队系统.github.io 基于Web的银行预约和排队系统打算对不同类型的排队问题和解决方案进行分析。 在线约会使用互联网为... 队列管理系统是一组开发用于分析和管理特定企业或组织的客户流的系统。
一本关于网络分析的书,主要采用网络微积分的数学工具。
Because the router has the entire packet at time t1, it can begin to transmit the packet to the receiving host at time t1. At time t2 = t1 + L/R2, the router completes transmission and the entire ...
AMQP,即Advanced Message Queuing Protocol,高级消息队列协议,是应用层协议的一个开放标准,为面向消息的中间件设计。消息中间件主要用于组件之间的解耦,消息的发送者无需知道消息使用者的存在,反之亦然。 AMQP...
The MAP/PH/N multi-server queuing system with broadcasting service discipline and server heating
HTB linux queuing discipline manual--userguide HTB 流量控制手册——用户指导 讲述linux htb调度算法和原理,原书的中文版,推荐
AMQP,即Advanced Message Queuing Protocol,高级消息队列协议,是应用层协议的一个开放标准,为面向消息的中间件设计。消息中间件主要用于组件之间的解耦,消息的发送者无需知道消息使用者的存在,反之亦然。 AMQP...
MQTT(Message Queuing Telemetry Transport,消息队列遥测传输)是 IBM 开发的一个即时通讯协议,有可能成为物联网的重要组成部分。MQTT 是基于二进制消息的发布/订阅编程模式的消息协议,如今已经成为 OASIS 规范...
Network Calculus: A Theory of Deterministic Queuing Systems for the Internet Author(s) Jean-Yves Le Boudec and Patrick Thiran Publisher: Springer; 1 edition (August 24, 2001) (August 17, 2011) ...