You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1019 B

#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
/*
先将所有同学按分数高者优先、序号小者优先进行双关键字排序。
然后求出分数线:即排名在 ⌊1.5m⌋ 的同学的分数。
最后找出成绩大于等于分数线的同学人数。
*/
int n, m;
struct Person {
int id, score;
bool operator<(const Person &b) const {
if (score != b.score) return score > b.score;
return id < b.id;
}
} person[N];
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> person[i].id >> person[i].score;
sort(person, person + n);
int k = m * 1.5;
// 一样分数的也要入围
while (k < n && person[k - 1].score == person[k].score) k++;
// 输出入围分数和入围人数
printf("%d %d\n", person[k - 1].score, k);
// 输出入围人数ID及分数
for (int i = 0; i < k; i++)
printf("%d %d\n", person[i].id, person[i].score);
return 0;
}