#include <bits/stdc++.h>
using namespace std;
struct Node {
int size;
int price;
bool operator < (const Node &b) const {
bool ret = this->size < b.size;
if(this->size == b.size) {
ret = this->price > b.price;
}
return ret;
}
};
int main() {
priority_queue<Node> pq;
for (int i = 0; i < 5; i++) {
pq.push(Node{i, 5 - i});
}
while (!pq.empty()) {
Node top = pq.top();
pq.pop();
printf("size:%d price:%d\n", top.size, top.price);
}
return 0;
}
priority_queue(优先队列)
于 2022-08-25 09:32:24 首次发布