蒟蒻10分求助!
查看原帖
蒟蒻10分求助!
167697
BartAllen楼主2021/12/10 16:01

代码如下:

#include<bits/stdc++.h>
using namespace std;
struct node {
	int num;
	int mark;
}a[10005];
int n, m;
bool cmp(node x, node y) {
	return x.mark > y.mark;
}
int main() {
	int i, p, mp, cnt = 0;
	cin >> n >> m;
	for (i = 1; i <= n; i++)
		cin >> a[i].num >> a[i].mark;
	sort(a + 1, a + n + 1, cmp);
	p = floor(m * 1.5);
	mp = a[p].mark;
	i = 1;
	while (a[i].mark >= mp) {
		i++;
		cnt++;
	}
	cout << mp << " " << cnt << endl;
	for (i = 1; i <= cnt; i++)
		cout << a[i].num << " " << a[i].mark << endl;
	return 0;
}
2021/12/10 16:01
加载中...