Skip to content

Commit 9706c51

Browse files
author
hangyeol
committed
95차 1번 문제풀이
1 parent eccce80 commit 9706c51

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

live9/test95/문제1/백한결.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import itertools
2+
3+
4+
def solution(k, dungeons):
5+
answer = -1
6+
7+
counts = []
8+
9+
p = itertools.permutations(dungeons, len(dungeons))
10+
11+
for i in p:
12+
counts.append(maxDungeons(k, i))
13+
14+
counts.sort()
15+
16+
return counts[-1]
17+
18+
19+
def maxDungeons(k, dungeons):
20+
count = 0
21+
health = k
22+
23+
for dungeon in dungeons:
24+
if dungeon[0] > health:
25+
break
26+
else:
27+
count += 1
28+
health -= dungeon[1]
29+
30+
return count

0 commit comments

Comments
 (0)