POJ 3633

来源:互联网 发布:win10怎么优化内存 编辑:程序博客网 时间:2024/05/21 06:36
#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_Nconst 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;}

0 0
原创粉丝点击