code
2023-01-13 16:38:54
发布于:山东
110阅读
0回复
0点赞
code
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e7+10;
int n,m,ans[maxn];
inline int read()
{
char c=getchar();
int x=0,s=1;
while(c<'0' or c>'9')
{
if(c=='-')
{
s=-1;
}
c=getchar();
}
while(c>='0' and c<='9')
{
x=x*10+c-'0';
c=getchar();
}
return x*s;
}
void write(int x)
{
if(x<0)
{
putchar('-'),x=-x;
}
if(x>9)
{
write(x/10);
}
putchar(x%10+'0');
return;
}
struct node
{
int k,s;
}arr[maxn];
bool cmp(node x,node y)
{
if(x.s>y.s)
{
return true;
}
else if(x.s==y.s)
{
if(x.k<y.k)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
signed main()
{
n=read();
m=read();
m=floor(m*1.5);
for(int i=1;i<=n;i++)
{
arr[i].k=read();
arr[i].s=read();
}
sort(arr+1,arr+n+1,cmp);
int sum=arr[m].s;
int p=m;
for(int i=m+1;i<=n;i++)
{
if(arr[i].s==sum)
{
p++;
}
else if(arr[i].s<sum)
{
break;
}
}
cout<<sum<<" "<<p<<endl;
for(int i=1;i<=p;i++)
{
cout<<arr[i].k<<" "<<arr[i].s<<endl;
}
return 0;
}
这里空空如也
有帮助,赞一个