#include <bits/stdc++.h>
using namespace std;
int n, m;
struct info {
int k, s;
}a[5009];
bool cmp (info x, info y) {
if (x.s > y.s) return true;
if (x.s == y.s && x.k < y.k) return true;
return false;
}
int main() {
cin >> n >> m;
m *= 1.5;
for (int i = 1; i <= n; i ++) cin >> a[i].k >> a[i].s;
sort(a + 1, a + 1 + n, cmp);
int cnt = 1;
while (cnt < m || a[cnt].s == a[cnt + 1].s) {
cnt ++;
}
cout << a[cnt].s << ' ' << cnt << endl;
for (int i = 1; i <= cnt; i ++) {
cout << a[i].k << ' ' << a[i].s << endl;
}
return 0;
}
NOIP 2009 普及组 分数线划定
最新推荐文章于 2024-08-23 20:46:36 发布
该博客展示了一个C++程序,程序首先读取整数n和m,然后读取n个结构体元素包含整数k和s。通过自定义比较函数对结构体数组进行排序,寻找m个最大值中第一个不重复的值及其索引,并输出结果。程序还输出了这m个最大值及其对应的s值。

529

被折叠的 条评论
为什么被折叠?



