UVA 10588—— Queuing at the doctors
来源:互联网 发布:古生物学就业 知乎 编辑:程序博客网 时间:2024/06/16 21:16
题意:给定n个工人和m个医生,然后进行体检,每个医生每秒接待一个工人,每个人都有一个体检项目顺序和时间,问最后一个员工完成体检的时间。
思路:优先队列模拟,建立m个项目的优先队列,当某个工人满足体检时间时,给该工人体检,然后push到下一个项目中去。
code:
#include <bits/stdc++.h>using namespace std;const int N=1005;int T,n,m;struct node{ int t,id; bool operator <(const node& B)const { return t > B.t || (t == B.t && id > B.id); }}p;priority_queue<node>Q[N];queue<int>q[N];int sol(){ int f = 1, ans = 0; while (f) { f = 0; for (int i = 0; i < m; i++) { if (!Q[i].empty()) { f = 1; node pe = Q[i].top(); if (ans < pe.t) continue; Q[i].pop(); q[pe.id].pop(); if (!q[pe.id].empty()) { pe.t = ans + 1; Q[q[pe.id].front()].push(pe); } } } ans++; } return ans - 1;}int main(){ scanf("%d",&T); int k,tp; while (T--){ scanf("%d%d",&n,&m); for (int i=0;i<n;i++){ p.id=i; scanf("%d%d",&p.t,&k); for (int j=0;j<k;j++){ scanf("%d",&tp); tp--; q[p.id].push(tp); } Q[q[p.id].front()].push(p); } //cout<<"bug"<<endl; printf("%d\n",sol()); }}
0 0
- UVA 10588—— Queuing at the doctors
- UVA - 10588 Queuing at the doctors (队列)
- UVA 10588 - Queuing at the doctors(优先队列)
- uva 10588 - Queuing at the doctors(优先队列)
- Queuing at the doctors
- UVA10588 - Queuing at the doctors(优先队列)
- HDU 2529 Queuing at the doctors 优先队列+模拟
- HDU——Queuing
- hdu2604——Queuing
- uva 1220——Party at Hali-Bula
- The Necklace ——UVA
- 【矩阵乘法再实践】HDU 2604——queuing
- 《Rework》——Throw less at the problem
- Most people stop at the Z — but not me!
- uva 1614——UVA 1614 - Hell on the Markets
- uva 701——The Archeologists\' Dilemma
- uva 1623——Enter The Dragon
- uva 10479——The Hendrie Sequence
- 安卓程序员个人角度浅析创业型公司败因
- 随堂笔记160314适配器和多态
- Spring MVC 方法参数是list
- 通俗易懂讲解 SVM(支持向量机)
- 2016蓝桥杯省赛B组题解
- UVA 10588—— Queuing at the doctors
- DOM操作样式
- 1016 average cow
- @EXPORT and @EXPORT_OK
- 尝试、热爱、坚持、致用、求新、跨域
- Java开发编程基础-4
- 随堂笔记160315工厂和代理模式
- 5w2h-是什么,是什么时代的产物
- u-boot分析 三 (u-boot.lds脚本)