1 条题解
-
1养猪场场长zms (njnu19210436) LV 9 MOD @ 2021-12-10 14:05:29
#include<bits/stdc++.h> using namespace std; #define N 100001 typedef struct stu { int id; int score; }Stu; void Sort(Stu a[], int n) { Stu t; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (a[i].score < a[j].score) { t = a[i]; a[i] = a[j]; a[j] = t; } } } for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (a[i].score == a[j].score) { if (a[i].id > a[j].id) { t = a[i]; a[i] = a[j]; a[j] = t; } } } } } void Output(Stu a[], int n, int k) { cout << a[k - 1].id << " " << a[k - 1].score << endl; } int main() { Stu a[N]; int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i].id >> a[i].score; } Sort(a, n); Output(a, n, k); return 0; }
- 1
信息
- ID
- 2914
- 难度
- 9
- 分类
- (无)
- 标签
- 递交数
- 1
- 已通过
- 1
- 通过率
- 100%
- 上传者