1 条题解
-
1
看清总评价的计算公式后利用
struct
和sort
排序即可。为了避免精度误差,建议按 (将原来的公式除以 )计算总评价,此时需要使用
long long
。(当然了,直接使用double
或long double
也是一个不错的选择。)#include <bits/stdc++.h> using namespace std; const int A = 20 + 2; struct Team { string b; int m; int n; int t; long long k; }; Team team[A]; bool cmp(Team x, Team y) { return x.k > y.k; } int main() { freopen("football.in", "r", stdin); freopen("football.out", "w", stdout); int T; cin >> T; while (T--) { int a; cin >> a; for (int i = 1; i <= a; i++) { cin >> team[i].b >> team[i].m >> team[i].n >> team[i].t; team[i].k = 1ll * team[i].t * (2ll * team[i].m + 1ll * team[i].n); } sort(team + 1, team + a + 1, cmp); for (int i = 1; i <= a; i++) { cout << team[i].b; if (i != a) cout << ' '; } cout << endl; } return 0; }
- 1
信息
- ID
- 146
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 2
- 标签
- 递交数
- 26
- 已通过
- 8
- 上传者