80pts求助
查看原帖
80pts求助
1269609
yiwugougou楼主2024/8/9 21:13

代码:

#include<bits/stdc++.h>
using namespace std;
struct Node{
    int bh,df;
}arr[5010];
int n,m;
bool cmp(Node x,Node y){
    if(x.df==y.df){
        return x.bh<y.bh;
    }
    return x.df>y.df;
}
int main(){
    cin>>n>>m;
    m*=1.5;
    for(int i=0;i<n;i++){
        cin>>arr[i].bh>>arr[i].df;
    }
    sort(arr,arr+n,cmp);
    int ans=0,M=arr[m].df;
    for(int i=0;i<n;i++){
        if(arr[i].df>=M){
            ans++;
        }
    }
    cout<<M<<' '<<ans<<endl;
    for(int i=0;i<ans;i++){
        cout<<arr[i].bh<<' '<<arr[i].df<<' '<<endl;
    }
    return 0;
}

结果:

额~~~

所以到底哪里错了!!!

2024/8/9 21:13
加载中...