-
[Level 2] 피로도(permutations)[프로그래머스] 코딩테스트 고득점 Kit/완전탐색 2023. 5. 1. 00:54
from itertools import permutations def solution(k, dungeons): answer = 0 for p in permutations(dungeons, len(dungeons)): temp = k count = 0 for need, spend in p: if temp >= need: temp -= spend count += 1 answer = max(answer, count) return answer
- permutations 통해 모든 순서 경우의 수 구하고 하나씩 실행해본 뒤 최대 던전 수 return하는 방식
'[프로그래머스] 코딩테스트 고득점 Kit > 완전탐색' 카테고리의 다른 글
[Level 2] 카펫 (0) 2023.05.01 [Level 2] 소수 찾기(permutations) (0) 2023.04.30 [Level 1] 모의고사(enumerate) (0) 2023.04.30 [Level 1] 최소직사각형 (0) 2023.04.30