AcWing 5620. 电脑采购
原题链接
简单
作者:
sky-koi
,
2024-10-31 23:46:03
,
所有人可见
,
阅读 1
#include <bits/stdc++.h>
using namespace std;
struct computer {
string name;
int R,S,D;
int performance;
}c[10010];
bool cmp(computer &c1, computer &c2) {
if (c1.performance != c2.performance)
return c1.performance > c2.performance;
return c1.name < c2.name;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> c[i].name >> c[i].R >> c[i].S >> c[i].D;
c[i].performance = 2 * c[i].R + 3 * c[i].S + c[i].D;
}
sort(c, c + n, cmp);
if (n >= 2) {
for (int i = 0; i < 2; i++) {
cout << c[i].name << endl;
}
} else if (n == 1){
cout << c[0].name << endl;
} else {
cout << "" << endl;
}
return 0;
}