问题标题: 酷町堂:1455

0
0

0
已采纳
王泽轩
王泽轩
资深天翼
资深天翼

函数:

bool cmp(int a,int b){
    if(s[a]==s[b]){return k[a]<k[b];}
    else{return s[a]>s[b];}
}

main里头:

scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
        cin>>k[sub[i]=i]>>s[i];
    }
    sort(sub+1,sub+n+1,cmp);
    f=s[sub[int(m*1.5)]];
    for(i=1;s[sub[i]]>=f;i++);
    printf("%d %d\n",f,i-1);
    for(i=1;s[sub[i]]>=f;i++){
        printf("%d %d\n",k[sub[i]],s[sub[i]]);
    }

定义:

 

int i,n,m,f,k[5001],s[5001],sub[5001];

头文件别忘

我要回答