Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- lock free stack
- making anagrams
- DirectX12
- string construction
- 프로그래밍공부
- gas
- boj 11657
- c++
- two characters
- DirectX
- 2025 프로그래머스 코딩챌린지 1차예선
- 브루트포스
- ice cream parlor
- boj 1074
- the longest increasing subsequence
- LCS
- find the town judge
- special string again
- count triplets
- pcce 기출문제 풀이
- the maximum subarray
- lock based stack
- find the running median
- 지게차와 크레인
- pccp 기출문제 풀이
- lock based queue
- boj 6443
- dp
- PCCE
- boj 1717
Archives
- Today
- Total
오구의코딩모험
[Python] 피로도 본문
반응형

[코딩테스트 고득점 KIT - 완전탐색]

순열을 이용하여 모든 피로도 소모 경우의 수를 계산해준다.
소모되어 줄어든 피로도를 HP 변수에 담으며,
남은 피로도인 HP가 탐험할 던전의 "최소 필요 피로도" 보다 높으면 피로도를 소모하여 탐험한다.
탐험 후 HP에서 소모한 피로도만큼 줄여준다.
끝
from itertools import permutations def solution(k, dungeons): answer = 0 ## permutations 순열 라이브러리 for dungeon in list(permutations(dungeons,len(dungeons))): # 탐험한 던전의 수 result = 0 # 남은 피로도 HP = k for root in dungeon: # 요구사항 if root[0] <= HP: result += 1 HP -= root[1] # 결과 if answer < result: answer = result return answer
반응형
'프로그래밍 공부 > 프로그래머스' 카테고리의 다른 글
[MySQL] 과일로 만든 아이스크림 고르기 (1) | 2023.01.04 |
---|---|
[Python] 소수 찾기 (0) | 2023.01.03 |
[Python] 카펫 (0) | 2023.01.02 |
[Python] H-Index (0) | 2023.01.02 |
[Python] K번째수 (0) | 2023.01.01 |
Comments