版权声明:菜鸟一枚~~ 有想法可在下面评论, 转载标明出处即可。 https://blog.csdn.net/KLFTESPACE/article/details/84888672
//结构体构造函数...要写的话两个都得写上,不然Node a;会出问题.....
//重载运算符优先队列里>是从小到大排列
//也可以写成这样....会减少一点语句执行次数
bool operator < (const Node& C) const{
return t > C.t || (t == C.t && num > C.num);
}
#include<iostream>
#include <queue>
#include <cstring>
using namespace std;
struct Node{
int t, num, p;
Node(int a, int b, int c){
num = a;
t = b;
p = c;
}
Node(){}
bool operator < (const Node& C) const{
if(t == C.t)
return num > C.num;
return t > C.t;
}
};
int main()
{
priority_queue<Node> q;
string s;
while(cin >> s && s[0]!='#'){
Node A;
cin >> A.num >> A.p;
A.t = A.p;
q.push(A);
}
int n;
cin >> n;
while(n--){
Node temp = q.top();
q.pop();
cout << temp.num << endl;
temp.t += temp.p;
q.push(temp);
}
return 0;
}