오답
import sys
input = sys.stdin.readline
def get_dwarfs(start):
if len(picked) == 7 and sum(picked) == 100:
for i in picked:
print (i)
return
for i in range(start, len(heights)):
picked.append(heights[i])
get_dwarfs(i+1)
picked.pop()
heights = []
picked = []
for _ in range(9):
heights.append(int(input()))
get_dwarfs(0)
정답
import sys
input = sys.stdin.readline
def get_dwarfs():
if len(picked) == 7 and sum(picked) == 100:
picked.sort()
for i in picked:
print (i)
exit()
for i in range(len(heights)):
if heights[i] not in picked:
picked.append(heights[i])
get_dwarfs()
picked.pop()
heights = []
picked = []
for _ in range(9):
heights.append(int(input()))
get_dwarfs()
'Computer Science > 백준 알고리즘' 카테고리의 다른 글
[백준] 2439번 별 찍기 - 2 (C++) (0) | 2022.03.16 |
---|---|
[백준] 2439번 별 찍기 - 1 (C++) (0) | 2022.03.15 |
[백준] 2231번 분해합 (파이썬) (0) | 2022.03.15 |
[백준] 2164번 카드2 (파이썬) (0) | 2022.03.14 |
[백준] 1991번 트리 순회 (파이썬) (0) | 2022.03.14 |