0
已解决
题目链接: 酷町堂:1480
#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
struct node{
int xh;
double cj;
}a[10005];
bool cmp1(node x,node y){
return x.cj<y.cj;
}
bool cmp2(node x,node y){
return x.xh<y.xh;
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i].xh>>a[i].cj;
}
sort(a+1,a+n+1,cmp1);
sort(a+1,a+n+1,cmp2);
cout<<a[m].xh<<" ";
printf("%.1f",a[m].cj);
return 0;
}
0
已采纳
不需要两个排序,用一个排序,cmp函数:
bool cmp(stu a,stu b){
if(a.score!=b.score) return a.score>b.score;
return a.id<b.id;
}
score就是你的cj,id就是你的xh
0
0