본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 29965번 Average scores

by 현장 2024. 11. 10.

-Code

from sys import stdin
input = stdin.readline

n = int(input())
m_total, j_total = 0, 0
m_cnt, j_cnt = 0, 0
m_res, j_res = 0, 0

for _ in range(n):
    a, b = input().split()
    b = int(b)

    if a == "M":
        m_total += b
        m_cnt += 1
    else:
        j_total += b
        j_cnt += 1

if m_cnt != 0:
    m_res = m_total / m_cnt
if j_cnt != 0:
    j_res = j_total / j_cnt

if m_res < j_res:
    print('J')
elif m_res > j_res:
    print('M')
else:
    print('V')