不知道自己错哪了,来个大佬解释一下,谢谢
include
include
include
include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int fin=floor(m*1.5);
int a[6000];
int b[6000];
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(int i=0;i<n;i++)
{
cin>>a[i]>>b[i];
}
int temp1,temp2;
for(int j=0;j<n-1;j++) //冒泡排序,序号和分数同时变换
{
temp1=0,temp2=0;
for(int i=0;i<n-1-j;i++)
{
if(b[i]<=b[i+1])
{
temp1=b[i];
temp2=a[i];
b[i]=b[i+1];
a[i]=a[i+1];
b[i+1]=temp1;
a[i+1]=temp2;
}
}
}
if(fin>=n)
fin=n;
cout<<b[fin-1]<<" ";
int count=0;
for(int i=0;i<n;i++)
{
if(b[i]>=b[fin-1])
{
count++;
}
}
cout<<count<<"\n";
for(int i=0;i<n;i++)
{
if(b[i]>=b[fin-1])
{
cout<<a[i]<<" "<<b[i]<<"\n";
}
}
return 0;
}