80分求助!
查看原帖
80分求助!
498049
Doctor_zhc楼主2022/1/29 09:06
#include<bits/stdc++.h>
using namespace std;
int n;
struct node{
	int value,ch,next;
};
node a[301];
bool cmp(node a,node b){
	if(a.value>b.value)
		return true;
	if(a.value==b.value){
		if(a.ch>b.ch)
			return true;
		else if(a.ch==a.ch){
			if(a.next<=b.next)
				return true;
			else
				return false;
		}
		else
			return false;
	}
	else
		return false;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int che,b,c;
		scanf("%d%d%d",&che,&b,&c);
		a[i].value=che+b+c;
		a[i].ch=che;
		a[i].next=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=5;i++)
		printf("%d %d\n",a[i].next,a[i].value);
	return 0;
}
2022/1/29 09:06
加载中...