A5.分数线划定 普及- 题解
2024-08-01 10:06:57
发布于:广东
3阅读
0回复
0点赞
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
struct Employee
{
int id, score;
};
int main()
{
int n, m; std::cin >> n >> m;
std::vector<Employee> a(n);
for (int i = 0; i < n; i++){
std::cin >> a[i].id >> a[i].score;
}
std::sort(a.begin(), a.end(), [&](Employee a, Employee b) -> bool
{
if (a.score != b.score) return a.score > b.score;
return a.id < b.id;
});
int scoreline = a[std::floor(m*1.5)-1].score;
std::cout << scoreline << ' ';
int admissions = 0;
for (int i = 0; i < n; i++)
{
if (a[i].score >= scoreline){
admissions ++;
}
else break;
}
std::cout << admissions << '\n';
for (int i = 0; i < admissions; i++){
std::cout << a[i].id << ' ' << a[i].score << '\n';
}
return 0;
}
这里空空如也
有帮助,赞一个