View Code of Problem 82

#include<stdio.h>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
struct st{
	char a[100],b[100];
	int c,d,e;
	}s[100];
	int cmp(st a, st b){
		return a.c+a.d+a.e>b.c+b.d+b.e;
	}
int main(){
     int n;
     scanf("%d", &n);
     	for(int i=0;i<n;i++){
     		 scanf("%s%s%d%d%d", &s[i].a,&s[i].b,&s[i].c,&s[i].d,&s[i].e);   	
		 }
		 int c1=0,d1=0,e1=0;
		 for(int i=0;i<n;i++){
		  c1+=s[i].c;
		    d1+=s[i].d;
		     e1+=s[i].e;
		 }
	
       printf("%d %d %d\n",c1/n,d1/n,e1/n);
       sort(s,s+n,cmp);
       printf("%s %s %d %d %d\n",s[0].a,s[0].b,s[0].c,s[0].d,s[0].e);
     	
     	
	 
	return 0;
}

Double click to view unformatted code.


Back to problem 82