AC题解
2023-07-15 15:59:18
发布于:广东
1阅读
0回复
0点赞
#include <iostream>
#include <algorithm>
using namespace std;
struct Student {
int id;
int score;
};
bool cmp(const Student& a, const Student& b) {
if (a.score != b.score) {
return a.score > b.score;
}
return a.id < b.id;
}
int main() {
int n, m;
cin >> n >> m;
Student stu[n];
for (int i = 0; i < n; i++) {
cin >> stu[i].id >> stu[i].score;
}
sort(stu, stu + n, cmp);
int line = stu[(m * 3 / 2) - 1].score;
while (stu[m - 1].score >= line) {
m++;
}
cout << line << " " << m - 1 << endl;
for (int i = 0; i < m - 1; i++) {
cout << stu[i].id << " " << stu[i].score << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个