题目描述
C++ 代码
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
struct nod
{
int sj , time , q;
bool operator < (const nod & t) const {
if(time != t.time) return time > t.time;
else return sj > t.sj;
} /* data */
};
int k;
char s[10];
priority_queue<nod> pq;
void init() {
while(cin >> s) {
if(s[0] == '#') break;
nod ID;
cin >> ID.sj >> ID.time;
ID.q = ID.time;
pq.push(ID);
}
cin >> k;
}
void print() {
while(k -- ) {
cout << pq.top().sj << '\n';
nod id;
id.sj = pq.top().sj ;
id.time = pq.top().time + pq.top().q;
id.q = pq.top().q;
pq.pop();
pq.push(id);
}
}
int main()
{
ios::sync_with_stdio(false), cin.tie(0);
init();
print();
return 0;
}