1396B - Stoned Game - CodeForces Solution


brute force constructive algorithms games greedy *1800

Please click on ads to support us..

Python Code:

for tc in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	s, m = sum(A), max(A)
	print('T\n' if s // 2 < m or s % 2 == 1 else 'HL\n')

C++ Code:

#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

typedef long long LL;
const int  N = 110;

int a[N];

int main()
{
    int T;
    cin >> T;
    while(T -- )
    {
        int n;
        cin >> n;
        LL sum=0;
        for(int i=1;i<=n;++i){
            cin>>a[i];
            sum+=a[i];
        }

        if(sum&1)puts("T");
        else {
            bool flag=false;
            for(int i=1;i<=n;++i)
                if(a[i]>sum/2)flag=true;
            if(flag)puts("T");
            else puts("HL");
        }
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

276D - Little Girl and Maximum XOR
1253C - Sweets Eating
1047A - Little C Loves 3 I
758D - Ability To Convert
733A - Grasshopper And the String
216A - Tiling with Hexagons
1351B - Square
1225A - Forgetting Things
1717A - Madoka and Strange Thoughts
1717B - Madoka and Underground Competitions
61B - Hard Work
959B - Mahmoud and Ehab and the message
802G - Fake News (easy)
1717C - Madoka and Formal Statement
420A - Start Up
1031A - Golden Plate
1559C - Mocha and Hiking
427B - Prison Transfer
330A - Cakeminator
426A - Sereja and Mugs
363A - Soroban
1585C - Minimize Distance
1506E - Restoring the Permutation
1539A - Contest Start
363D - Renting Bikes
1198D - Rectangle Painting 1
1023B - Pair of Toys
1725A - Accumulation of Dominoes
1675E - Replace With the Previous Minimize
839A - Arya and Bran