uva 1203(优先队列)

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

#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;
}

 

posted on 2017-10-26 20:43  发牌员  阅读(199)  评论(0)    收藏  举报

导航