본문 바로가기
Programming/Python

[프로그래머스] 피로도

by 왕밤빵도라에몽 2025. 4. 10.
728x90

기본 아이디어

  • 가능한 경우의 수가 크지 않아 모든 경우의 수를 구해도되겠다
  • 순열이다
from itertools import permutations

def solution(k, dungeons):
    max_count = 0
    for order in permutations(dungeons):
        count = 0
        fatigue = k
        for required, cost in order:
            if required > fatigue:
                break
            fatigue -= cost
            count += 1
        max_count = max(max_count, count)
    return max_count
  • permutations으로 그냥 구현하면된다!
728x90

'Programming > Python' 카테고리의 다른 글

[프로그래머스] 모음사전  (0) 2025.04.12
[프로그래머스] 전화번호 목록  (0) 2025.04.12
[프로그래머스] 가장 큰 수  (0) 2025.04.10
[프로그래머스] 올바른 괄호  (0) 2025.04.09
[프로그래머스] 카펫  (0) 2025.04.09