지나가던 개발자

[Python] 백준 2456번(나는 학급회장이다) 문제 풀이 본문

PS/Python

[Python] 백준 2456번(나는 학급회장이다) 문제 풀이

KwonYongHyeon 2023. 7. 13. 21:03

 

tensyu = [0, 0, 0]
santen = [0, 0, 0]
niten = [0, 0, 0]
for i in range(int(input())):
    a = list(map(int, input().split()))
    tensyu[0] += a[0]
    tensyu[1] += a[1]
    tensyu[2] += a[2]
    if a[0] == 3:
        santen[0] += 1
    elif a[1] == 3:
        santen[1] += 1
    else:
        santen[2] += 1
    if a[0] == 2:
        niten[0] += 1
    elif a[1] == 2:
        niten[1] += 1
    else:
        niten[2] += 1
#print(tensyu, santen, niten)
if len(set(tensyu)) == len(tensyu):
    print(tensyu.index(max(tensyu))+1, max(tensyu))
else:
    printed = False
    if len([x for x in santen if x==max(santen)])==1:
        if tensyu[santen.index(max(santen))] == max(tensyu):
            print(santen.index(max(santen))+1, max(tensyu))
            printed = True
    if not printed:
        if len([x for x in niten if x==max(niten)])==1:
            if tensyu[niten.index(max(niten))] == max(tensyu):
                print(niten.index(max(niten))+1, max(tensyu))
                printed = True
    if not printed:
        print(0, max(tensyu))

 

백준... 굉장히 오랜만에 푸는데 감이 다 죽은 것 같다. 브론즈I 문제를 이렇게 길게 풀다니.

Comments