10分求解
查看原帖
10分求解
848012
Nightmare486楼主2024/7/12 10:35

#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;
int n,m,ans=0;
struct people{
	string id;
	int socer;
}peo[5005];

bool cmp(people &a, people &b){
	if(a.socer==b.socer){
		if(a.id<b.id)
		return 1;
	}
	else return a.socer>b.socer;
	
}
int main(){
	cin>>n>>m;
	int mun=m*1.5;
	
	for(int i=0;i<n;i++){
		cin>>peo[i].id>>peo[i].socer;
	}
	sort(peo,peo+n,cmp);
	
	int pass=peo[mun-1].socer;
	
	for(int j=0;j<n;j++){
		if(peo[j].socer>=pass){
			ans++;
		}
	}
	cout<<pass<<" "<<ans<<endl;
	for(int k=0;k<ans;k++){
		cout<<peo[k].id<<" "<<peo[k].socer<<endl;
	}
	return 0;
}


看过题解感觉和我的代码相差不大,但评测只有10分,过了第二个点,下载第一个的数据时,发现和我代码的输出相同,但就是过不去

2024/7/12 10:35
加载中...