-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을 통해 출력하니 해결이 되었습니다.
'Beakjoon&프로그래머스 > 파이썬' 카테고리의 다른 글
[백준/파이썬] 31260번 ПРАВОЪГЪЛНИК (0) | 2024.12.22 |
---|---|
[백준/파이썬] 30841번 Ложки (0) | 2024.12.21 |
[백준/파이썬] 25084번 Infinity Area (0) | 2024.12.19 |
[백준/파이썬] 32969번 학술대회 참가신청 (1) | 2024.12.18 |
[백준/파이썬] 32888번 Consolidating Windows (0) | 2024.12.17 |