极限压缩!!!
2023-07-27 16:29:10
发布于:广东
147阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;struct Weapon {string name;int attack;int price;};bool compare(const Weapon& w1, const Weapon& w2) {if (w1.attack == w2.attack) return w1.price < w2.price;return w1.attack > w2.attack;}int main() {int n, k;cin >> n >> k;vector<Weapon> weapons(n);for(int i = 0; i < n; i++) cin >> weapons[i].name >> weapons[i].attack >> weapons[i].price;sort(weapons.begin(), weapons.end(), compare);for (int i = 0; i < k; i++) cout << weapons[i].name << endl;return 0;}
全部评论 2
6
2024-05-28 来自 广东
1布什戈门
2024-08-31 来自 北京
0
有帮助,赞一个