来自New Bing的题解(未优化)
2023-04-01 20:42:05
发布于:澳大利亚
51阅读
0回复
0点赞
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 5010;
struct Student
{
int id;
int score;
}stu[N];
bool cmp(Student a, Student b)
{
if(a.score != b.score) return a.score > b.score;
else return a.id < b.id;
}
int main()
{
int n, m;
cin >> n >> m;
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;
}
这里空空如也
有帮助,赞一个