Участник:Dionidgy/BRKPR

Материал из DISCOPAL
Перейти к: навигация, поиск

https://www.codechef.com/problems/BRKPR

tests = int(input())
for test in range(tests):
    N = int(input())
    Pinkman, White = 0, 0
    money = list(map(int, input().split()))
    money.sort(reverse = True)
    money.append(0)
    queue = input().split()
    for i in range((N+1) // 2):
        if queue[i] == 'H':
            White += money[2*i]
            Pinkman += money[2*i+1]
        else:
            White += money[2*i+1]
            Pinkman += money[2*i]
    if Pinkman > White:
        print('Pinkman {0}'.format(Pinkman))
    elif Pinkman < White:
        print('Mr. White {0}'.format(White))
    else:
        print(-1)