您的位置:首页 > 其它

POJ 3633

2015-08-20 16:25 337 查看
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<list>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>

using namespace std;

#define MAX_N
const int INF = 0x3f3f3f3f;
struct node
{
    int id, time, p;
}o;
struct cmp
{
    bool operator()(node a, node b)
    {
        if(a.time == b.time)
            return a.id > b.id;
        return a.time > b.time;
    }
};

int main()
{
    priority_queue<node, vector<node>, cmp > pq;
    char str[20];
    int n, m;
    while(scanf("%s", &str))
    {
        if(str[0] == '#')
            break;
        scanf("%d%d", &n, &m);
            o.id = n;
            o.p = m;
            o.time = m;
            pq.push(o);
    }
    int k;
    scanf("%d", &k);
    while(k--)
    {
        node l = pq.top();
        pq.pop();
        cout<<l.id<<endl;
        l.time += l.p;
        pq.push(l);
    }

    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: