#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;
}
POJ 3633
最新推荐文章于 2015-08-27 11:05:19 发布