10588 - Queuing at the doctors
2024-09-14 16:14:52
这题wa 了 八次 你说 巨弱 orz 大神 总结一下 没有将所有的情况考虑清楚 ,当有的时候一个人已经全部看完的时候 别的人还没开始 但是我就把他给结束了
#include <iostream>
#include<queue>
#include<cstdio>
using namespace std;
const int maxn=1100;
struct point{
long long ti;
int num;
bool operator <(const point &a)const{
return ti>a.ti||(ti==a.ti&&num>a.num);
}
};
priority_queue<point> doc[maxn];
queue<int>pat[maxn];
int main()
{
int t;
point temp;
scanf("%d",&t);
while(t--){
int n,m,d;
long long first=0,after=0,cur,ans=0,T;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
int cas;
cin>>temp.ti>>cas;
temp.num=i;
if(cas>0){
++first; scanf("%d",&d); doc[d].push(temp); cas--;
}
while(cas--){
scanf("%d",&d);
++first;
pat[i].push(d);
}
}
cur=-1;
T=-2;
while(first!=after){ if(T>cur) cur=T;
else cur++;
T=100000000;
for(int i=1;i<=m;i++)
if(!doc[i].empty()){
temp=doc[i].top();
if(temp.ti<=cur){
T=cur;
++after;
ans=cur+1;
doc[i].pop();
if(!pat[temp.num].empty()){
d=pat[temp.num].front();
pat[temp.num].pop();
temp.ti=cur+1;
doc[d].push(temp);
}
}
else T=T>temp.ti?temp.ti:T;
}
if(first==after) break; }
cout<<ans<<endl;
} return 0;
}
最新文章
- LeetCode:Count and Say
- 利用jquery发送form表单
- MATLAB寻找数组前k个大值
- MUI(3)
- MVP
- 改善C#公共程序类库质量的10种方法
- [MetaHook] Quake FMOD function
- 137. Single Number II——问题是查找,本质是hash查找,只是记录的是32 bit中各个位出现次数而已
- poj 1247 The Perfect Stall 裸的二分匹配,但可以用最大流来水一下
- lght oj 1257 - Farthest Nodes in a Tree (II) (树dp)
- 射频识别技术漫谈(14)&mdash;&mdash;S50与S70存取控制【worldsing笔记】
- Cocos2d-x3.0TestCpp文件夹笔记(二)
- WPF仿微软事件和属性窗体,效果更炫!
- Where Jboss7.1 take war application to deploy--reference
- 管理SQL Server数据库服务器的安全防范原则
- Mysql中Key与Index的区别
- eclipse创建的maven项目无法部署到tomcat
- Java基础 成员变量的继承与覆盖
- byte在计算机中的存储方式--Double.byteValue()的输出结果思考
- Linux下通过server-status监控性能