#include<bits/stdc++.h>
using namespace std;
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)
#define MOD 1000000007
#define MX 100010
struct Z{
int id, val, inc;
bool operator < (Z const p) const{
if(val==p.val) return id>p.id;
return val>p.val;
}
};
Z z;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
int tc, kk=1, n, k;
string s;
char ch;
priority_queue<Z>pq;
while(cin>>s && s!="#")
{
cin>>z.id>>z.inc;
z.val=z.inc;
pq.push(z);
}
cin>>k;
while(k--)
{
z = pq.top();
pq.pop();
cout<<z.id<<"\n";
z.val+=z.inc;
pq.push(z);
}
return 0;
}
No comments:
Post a Comment