View Code of Problem 63

#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
typedef struct pe
{
    char name[100];
    int h,m;
};

bool cmp1(pe a,pe b)
{
    return a.h>b.h;
}

bool cmp2(pe a,pe b)
{
    return a.m>b.m;
}
int main()
{
    int n;
    scanf("%d",&n);
    pe man[n];
    for(int i=0;i<n;++i)
    {
        scanf("%s",man[i].name);
        scanf("%d",&man[i].h);
        scanf("%d",&man[i].m);
    }
    sort(man,man+n,cmp1);//h
    int rank_h=0;
    for(int i=0;i<n;++i)
    {
        if(strcmp(man[i].name,"Suxiao")!=0)
        {
            rank_h++;
        }
        else
            break;
    }

    sort(man,man+n,cmp2);//m
    int rank_m=0;
    for(int i=0;i<n;++i)
    {
        if(strcmp(man[i].name,"Suxiao")!=0)
        {
            rank_m++;
        }
        else
            break;
    }
    //printf("%d %d",rank_h,rank_m);
    if(rank_h<rank_m)
        printf("HEIGHT");
    else if(rank_h>rank_m)
    {
        printf("MONEY");
    }
    else
        printf("EQ");







}

Double click to view unformatted code.


Back to problem 63