设为首页 加入收藏

TOP

UVA - 10588 Queuing at the doctors (队列)(二)
2015-07-20 17:44:40 来源: 作者: 【 】 浏览:4
Tags:UVA 10588 Queuing the doctors 队列
:每个项目都用一个优先队列模拟,处理一个人后,就将这个人丢到它的下一项目对应的队列中
#include 
    
     
#include 
     
       #include 
      
        #include 
       
         #include 
        
          using namespace std; const int maxn = 1100; struct node { int t, id; bool operator <(const node &a) const { if (t == a.t) return id > a.id; return t > a.t; } }; int n, m; priority_queue
         
           p[maxn]; queue
          
            q[maxn]; int main() { int t; scanf("%d", &t); while (t--) { scanf("%d%d", &n, &m); int x, num, a; node now; for (int i = 0; i < n; i++) { now.id = i; scanf("%d%d", &x, &num); while (num--) { scanf("%d", &a); a--; q[i].push(a); } now.t = x; p[q[i].front()].push(now); } int ans = 0, flag = 1; while (flag) { flag = 0; for (int i = 0; i < m; i++) { if (!p[i].empty()) { flag = 1; now = p[i].top(); if (now.t > ans) continue; p[i].pop(); q[now.id].pop(); if (!q[now.id].empty()) { now.t = ans + 1; p[q[now.id].front()].push(now); } } } ans++; } printf("%d\n", ans-1); } return 0; }
          
         
        
       
      
     
    


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇LA 6459 Infinite Go (模拟,搜索) 下一篇BZOJ 2241 SDOI2011 打地鼠 线性..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·常用meta整理 | 菜鸟 (2025-12-25 01:21:52)
·SQL HAVING 子句:深 (2025-12-25 01:21:47)
·SQL CREATE INDEX 语 (2025-12-25 01:21:45)
·Shell 传递参数 (2025-12-25 00:50:45)
·Linux echo 命令 - (2025-12-25 00:50:43)