题目链接:https://www.luogu.org/problemnew/show/P1068
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=5000+10;
int m,n;
struct Node{
int id;
int score;
}A[maxn];
bool cmp(Node x,Node y){
if(x.score != y.score ) return x.score>y.score;
else return x.id<y.id;
}
int main(void){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d%d",&A[i].id,&A[i].score);
}
sort(A+1,A+n+1,cmp);
m=m+m/2;
while(m+1<=n && A[m].score==A[m+1].score) m++;
printf("%d %d\n",A[m].score,m);
for(int i=1;i<=m;i++){
printf("%d %d%c",A[i].id,A[i].score,'\n');
}
return 0;
}
网友评论