LV 2: 피로도

ewillwin·2023년 8월 21일
0

문제 링크

LV 2: 피로도


구현 방식

  • len(dungeons)가 1이상 8이하이기 때문에 permutations를 이용해서 완전 탐색으로 풀었다

코드

from itertools import permutations

def solution(k, dungeons):
    
    max_result = 0
    for dgs in tuple(permutations(dungeons)):
        local_k = k
        local_max_result = 0
        for dg in dgs:
            need, will_use = dg
            if need <= local_k:
                local_k -= will_use
                local_max_result += 1
            else:
                break

        max_result = max(max_result, local_max_result)
    return max_result
profile
💼 Software Engineer @ LG Electronics | 🎓 SungKyunKwan Univ. CSE

0개의 댓글