1 条题解
-
0
#include <bits/stdc++.h> #define int long long // 仅在需要大整数时使用,memset 数组为 0x3f 时去掉 #define INF 0x3f3f3f3f #define PII pair<int, int> #define ULL unsigned long long #define PIII tuple<int, int, int> #define all(v) v.begin(), v.end() #define debug(a) cout << #a << " = " << a << endl; using namespace std; constexpr int N = 1 * 1e6 + 10, M = 5 * 1e3 + 10; struct Stu { int id, a, b, c, total; }; void solve() { int n; cin >> n; vector<Stu> v(n); for (int i = 0; i < n; i++) { cin >> v[i].a >> v[i].b >> v[i].c; v[i].id = i + 1; v[i].total = v[i].a + v[i].b + v[i].c; } sort(v.begin(), v.end(), [](const Stu &x, const Stu &y) { if (x.total != y.total) return x.total > y.total; if (x.a != y.a) return x.a > y.a; if (x.b != y.b) return x.b > y.b; if (x.c != y.c) return x.c > y.c; return x.id < y.id; }); for (int i = 0; i < 5; i++) { cout << v[i].id << " " << v[i].total << " " << v[i].a << " " << v[i].b << " " << v[i].c << "\n"; } } signed main() { ios::sync_with_stdio(0); cin.tie(nullptr), cout.tie(nullptr); int _ = 1; // cin >> _; while (_--) { solve(); } return 0; } /** * author: Nijika_jia * description: C++17 Algorithm Template for Competitive Programming */
- 1
信息
- ID
- 5635
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 2
- 标签
- 递交数
- 42
- 已通过
- 13
- 上传者