피로도
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
- 내 풀이
- 순열(permutations) 이용
- 가능한 순서를 모두 적용해보면서 최댓값 구함
from itertools import permutations
def solution(k, dungeons):
count=0
answer=0
k2=k
n= len(dungeons)
lst=[i for i in permutations(range(n),n)]
for ls in lst:
for l in ls:
if k2>=dungeons[l][0]:
k2-=dungeons[l][1]
count+=1
answer=max(answer,count)
count=0
k2=k
return answer
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
| [프로그래머스] [Level 2] [완전탐색] 전력망을 둘로 나누기 (0) | 2022.08.21 |
|---|---|
| [프로그래머스] [Level 2] [완전 탐색] 조이스틱 (0) | 2022.08.18 |
| [프로그래머스] [Level 2] [완전탐색] 소수 찾기 (0) | 2022.07.28 |
| [프로그래머스] [Level 2] [Heap] 더 맵게 (0) | 2022.07.26 |
| [프로그래머스] [Level 2] [스택/큐] 프린터 (0) | 2022.07.23 |