排序
2024-07-02 17:15:29
发布于:上海
9阅读
0回复
0点赞
排序再模拟就行啦~
提示:2010 世博会在上海召开。
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
struct node{
int a,b;
}a[5005];
inline bool cmp(node x,node y){
if(x.b==y.b) return x.a<y.a;
return x.b>y.b;
}
int main(){
int n,m;
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d %d",&a[i].a,&a[i].b);
sort(a+1,a+1+n,cmp);
int w=a[m+(m>>1)].b,cnt;
for(cnt=1;a[cnt+1].b>=w;cnt++);
printf("%d %d\n",w,cnt);
for(int i=1;i<=cnt;i++) printf("%d %d\n",a[i].a,a[i].b);
return 0;
}
这里空空如也
有帮助,赞一个