[python] ํ๋ก๊ทธ๋๋จธ์ค - ํผ๋ก๋
https://school.programmers.co.kr/learn/courses/30/lessons/87946
ํ๋ก๊ทธ๋๋จธ์ค
์ฝ๋ ์ค์ฌ์ ๊ฐ๋ฐ์ ์ฑ์ฉ. ์คํ ๊ธฐ๋ฐ์ ํฌ์ง์ ๋งค์นญ. ํ๋ก๊ทธ๋๋จธ์ค์ ๊ฐ๋ฐ์ ๋ง์ถคํ ํ๋กํ์ ๋ฑ๋กํ๊ณ , ๋์ ๊ธฐ์ ๊ถํฉ์ด ์ ๋ง๋ ๊ธฐ์ ๋ค์ ๋งค์นญ ๋ฐ์ผ์ธ์.
programmers.co.kr
from itertools import permutations
def solution(k, dungeons):
answer = 0
dungeons_N = len(dungeons)
for permus in permutations(dungeons,dungeons_N):
temp_k = k
cnt=0
for permu in permus:
if permu[0] <= temp_k:
temp_k -=permu[1]
cnt+=1
if answer < cnt:
answer = cnt
return answer
'Problem Solving > PROGRAMMERS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[python] ํ๋ก๊ทธ๋๋จธ์ค - ์ซ์์ ํํ (0) | 2022.11.15 |
---|---|
[python] ํ๋ก๊ทธ๋๋จธ์ค - ์์์ฐพ๊ธฐ (0) | 2022.11.06 |
[python]ํ๋ก๊ทธ๋๋จธ์ค - ๊ฒ์ ๋งต ์ต๋จ๊ฑฐ๋ฆฌ (0) | 2022.11.02 |
[python]ํ๋ก๊ทธ๋๋จธ์ค - ์ฌ๋ฐ๋ฅธ ๊ดํธ (0) | 2022.11.01 |
[python] ํ๋ก๊ทธ๋๋จธ์ค - ํ๋ฆฐํฐ (0) | 2022.10.31 |
๋๊ธ