20分 求助!!
查看原帖
20分 求助!!
1145634
wangzhihong10002楼主2025/1/9 14:49
#include<bits/stdc++.h>
using namespace std;
int n,k;
struct node{
	int a[110];
}b[110];
bool cmp(node x,node y){
	int s1=0,s2=0;
	for(int i=1;i<=k;i++){
		if(x.a[i]>=y.a[i]){
			s1++;
		}
		else{
			s2++;
		}
	} 
	if(s1!=s2){
		return s1>s2;
	}
	else{
		return x.a[k+1]<y.a[k+1];
	}
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			cin>>b[i].a[j];
		}
		b[i].a[k+1]=i;
	}
	sort(b+1,b+1+n,cmp);
	cout<<b[1].a[k+1]<<endl<<b[2].a[k+1];
	return 0;
}
2025/1/9 14:49
加载中...