简单说下思路 首先创建二维数组或结构体数组(可能这个好写点),这里采用递归排序法(因为是在递归那一章里的题),必须先对编号进行排序(这样才能输出正确),再对笔试成绩进行排序。 笔试及格进面试的人数中,最后一名成绩都是一样的,只需要判断成绩是否一致,一致人数就+1。 然后输出即可。 小白一枚,题目挺简单的,有大佬有新解欢迎在评论区讨论。

void merge_sort_recursive1(int (*arr)[2], int (*reg)[2], int start, int end) {
    if (start >= end)
        return;
    int len = end - start, mid = (len >> 1) + start;
    int start1 = start, end1 = mid;
    int start2 = mid + 1, end2 = end;
    merge_sort_recursive1(arr, reg, start1, end1);
    merge_sort_recursive1(arr, reg, start2, end2);
    int k = start;
    while (start1 <= end1 && start2 <= end2)
        reg[k++][0] = arr[start1][0] <= arr[start2][0] ? (reg[k][1]=arr[start1][1],arr [start1++][0]): (reg[k][1]=arr[start2][1],arr [start2++][0]);
    
	while (start1 <= end1)
        reg[k][0] = arr[start1][0],reg[k++][1] = arr[start1++][1];
    while (start2 <= end2)
        reg[k][0] = arr[start2][0],reg[k++][1] = arr[start2++][1];
    
	for (k = start; k <= end; k++)
    	
	    arr[k][0] = reg[k][0],arr[k][1]=reg[k][1];
}
 void merge_sort_recursive(int (*arr)[2], int (*reg)[2], int start, int end) {
    if (start >= end)
        return;
    int len = end - start, mid = (len >> 1) + start;
    int start1 = start, end1 = mid;
    int start2 = mid + 1, end2 = end;
    merge_sort_recursive(arr, reg, start1, end1);
    merge_sort_recursive(arr, reg, start2, end2);
    int k = start;
    while (start1 <= end1 && start2 <= end2)
        reg[k++][1] = arr[start1][1] >= arr[start2][1] ? (reg[k][0]=arr [start1][0],arr[start1++][1] ): (reg[k][0]=arr [start2][0],arr[start2++][1]);
    
	while (start1 <= end1)
       { reg[k][0] = arr[start1][0];reg[k++][1] = arr[start1++][1];}
    while (start2 <= end2)
        {reg[k][0] = arr[start2][0];reg[k++][1] = arr[start2++][1];}
    
	for (k = start; k <= end; k++)
	    arr[k][0] = reg[k][0],arr[k][1]=reg[k][1];
}
void merge_sort(int (*arr)[2], const int len) {
    int reg[len][2];
	merge_sort_recursive1(arr,reg,0,len-1);
    merge_sort_recursive(arr, reg, 0, len - 1);
}

int main()
{
 int n,m,a[5000][2];
 scanf("%d%d",&n,&m);
 for(int i=0;i<n;i++)
 	scanf("%d%d",&a[i][0],&a[i][1]);
 	
	  
 	merge_sort(a,n);
 	
 	
 	int i=m*1.5;while(a[i-1][1]==a[i][1]) i++;
	 printf("%d %d\n",a[i-1][1],i);	
	 	for(int j=0;j<i;j++)
	 printf("%d %d\n",a[j][0],a[j][1]);
return 0;
}