题解
2024-12-01 18:08:26
发布于:广东
3阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct node{
int x,y;
}a[5005];
bool cmp(node a,node b){
if(a.y != b.y) return a.y > b.y;
else return a.x < b.x;
}
int main(){
int n,m;
cin >> n >> m;
for(int i = 1;i <= n;i ++){
cin >> a[i].x >> a[i].y;
}
int x = m * 3 / 2;
sort(a + 1,a + n + 1,cmp);
vector<node> ans;
int last_score;
for(int i = 1;i <= x;i ++){
ans.push_back(a[i]);
last_score = a[i].y;
}
for(int i = x + 1;i <= n;i ++){
if(a[i].y == last_score){
ans.push_back(a[i]);
}
}
cout << a[x].y << " " << ans.size() << endl;
for(int i = 0;i < ans.size();i ++) cout << ans[i].x << " " << ans[i].y << endl;
return 0;
}
这里空空如也
有帮助,赞一个