https://school.programmers.co.kr/learn/courses/30/lessons/87946?language=python3#
def solution(k, dungeons):
orders = []
visit = [False] * len(dungeons)
def generate(d):
if len(d) == len(dungeons):
orders.append(d)
return
for i in range(0, len(dungeons)):
if visit[i] == False:
visit[i] = True
generate(d + [i])
visit[i] = False
generate([])
answer = 0
for order in orders:
remain = k
complete = 0
for i,stage in enumerate(order):
if remain >= dungeons[stage][0]:
remain -= dungeons[stage][1]
complete += 1
else:
break
answer = max(answer, complete)
return answer
[프로그래머스] 타겟 넘버 (0) | 2023.12.21 |
---|---|
[프로그래머스] 뉴스 클러스터링 (0) | 2023.12.21 |
[프로그래머스] 프로세스 (1) | 2023.12.20 |
[프로그래머스] 할인 행사 (0) | 2023.12.18 |
[프로그래머스] H-Index (0) | 2023.12.18 |