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

[백준/파이썬] 32500번 Dishonest Lottery

by 현장 2024. 12. 20.

-Code

from collections import defaultdict

lottery = defaultdict(int)
n = int(input())

for _ in range(n * 10):
    nums = list(map(int, input().split()))
    for num in nums:
        lottery[num] += 1

res = [num for num, cnt in lottery.items() if cnt > n * 2]

if res:
    print(" ".join(map(str, sorted(res))))
else:
    print(-1)

출력을 *sorted(res)로 했더니 타입 에러가 생겨서 join을 통해 출력하니 해결이 되었습니다.