Skip to content

Commit a3f301c

Browse files
committed
98차 1번 문제 다시 풀이
1 parent 7b655f6 commit a3f301c

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

live9/test98/문제1/박희경.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,23 @@
33
input = sys.stdin.readline
44

55
n, m = map(int, input().split())
6-
a = list(map(int, input().split()))
6+
a = [1] + list(map(int, input().split()))
77

8-
i = 1
9-
dp = [0] * (n + 1)
10-
dp[0] = 1
8+
def snow(size, time, idx):
9+
global res
1110

12-
while m > 0 or i <= n:
13-
# print(i, m, dp)
14-
if dp[i-1] + a[i+1] > dp[i-1]//2 + a[i+2]:
15-
dp[i] = dp[i-1] + a[i+1]
16-
print("굴리기", dp)
17-
i += 1
18-
else:
19-
dp[i] = dp[i-1]//2 + a[i+2]
20-
print("던지기", dp)
21-
i += 2
22-
m -= 1
11+
if time > m:
12+
return
13+
if time <= m:
14+
res = max(res, size)
15+
if idx + 1 <= n:
16+
snow(size + a[idx + 1], time + 1, idx + 1)
17+
if idx + 2 <= n:
18+
snow(size // 2 + a[idx + 2], time + 1, idx + 2)
2319

24-
print(dp)
20+
res = 0
21+
snow(1, 0, 0)
22+
print(res)
2523

2624
"""
2725
10 5

0 commit comments

Comments
 (0)