LightOJ 1249 - Chocolate Thief

//Next Codeforces Round #354 (Div. 2)
#include<bits/stdc++.h>

//#include<cstdio>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>

using namespace std;

#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
//#define i64 long long
#define high 105

typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<LL , multiset<string> >mmsll;
typedef vector<string>vs;

struct my
{
    string s ;
    LL x;
};

my ar[high];

bool cmp(my a , my b)
{
    return a.x > b.x;
}

int main()
{
    fast;
    int t,tc=0, n , i , l , w ,h ;

    cin >> t;

    while(t--)
    {
        cin >> n;

        for(i=0; i<n; i++)
        {
            cin >> ar[i].s;
            cin >> l >> w >> h;
            ar[i].x = l*w*h;
        }

        sort(ar, ar+n, cmp);

        cout << "Case " << ++tc << ": ";

        if(ar[0].x != ar[n-1].x)
        {
            cout << ar[0].s << " took chocolate from " << ar[n-1].s << "\n";
        }

        else
        {
            cout << "no thief\n";
        }
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number