📖 완전탐색 > 피로도
📖What I thought
- 탐험 가능한 최대 던전 수를 구하려면? 던전 순서 바꿔가며 체크
- 던전 돌면서 최소 필요 피로도 이상인지 체크
- 이상이면? 던전 +1 피로도 소모
- 이상이 아니라면? 해당 던전 패스
- 조건 그대로 구현만 그대로 해주자
📖풀이
📎구현
from itertools import permutations
def solution(k, dungeons):
max_cnt = 0
perm = permutations(dungeons)
for p in perm:
temp_k = k
cnt = 0
for need, use in p:
if need <= temp_k:
cnt += 1
temp_k -= use
max_cnt = max(max_cnt, cnt)
return max_cnt📖What I learned
permutation객체는 iterable한 객체라 반복문에 사용 가능