码迷,mamicode.com
首页 > 其他好文 > 详细

uva 1203(优先队列)

时间:2017-10-26 23:00:41      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:main   优先队列   mes   ret   ++   break   names   ace   clu   

无话可说,我记得自己以前做过的啊,为什么显示没做过呢。。。。。。

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
const int maxn=1000+100;
struct note
{
    int id;
    int num;
    int jal;
    bool operator <(const note &p) const
    {
        return (num>p.num)||(num==p.num&&id>p.id);
    }
}aa[maxn];
int main()
{   string ss;
    int cnt=0;
    priority_queue<note> pq;
     while(cin >> ss)
     {
         if(ss[0]==R)
         {
              cnt++;
             scanf("%d%d",&aa[cnt].id,&aa[cnt].num);
             aa[cnt].jal=aa[cnt].num;
             pq.push(aa[cnt]);
         }
         else break;
     }
     int k;
     scanf("%d",&k);
     while(k--)
     {
         note nn=pq.top();
         pq.pop();
         printf("%d\n",nn.id);
         nn.num=nn.num+nn.jal;
         pq.push(nn);
     }
    return 0;
}

 

uva 1203(优先队列)

标签:main   优先队列   mes   ret   ++   break   names   ace   clu   

原文地址:http://www.cnblogs.com/Wangwanxiang/p/7739270.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!