We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7b655f6 commit a3f301cCopy full SHA for a3f301c
1 file changed
live9/test98/문제1/박희경.py
@@ -3,25 +3,23 @@
3
input = sys.stdin.readline
4
5
n, m = map(int, input().split())
6
-a = list(map(int, input().split()))
+a = [1] + list(map(int, input().split()))
7
8
-i = 1
9
-dp = [0] * (n + 1)
10
-dp[0] = 1
+def snow(size, time, idx):
+ global res
11
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
+ if time > m:
+ return
+ if time <= m:
+ res = max(res, size)
+ if idx + 1 <= n:
+ snow(size + a[idx + 1], time + 1, idx + 1)
+ if idx + 2 <= n:
+ snow(size // 2 + a[idx + 2], time + 1, idx + 2)
23
24
-print(dp)
+res = 0
+snow(1, 0, 0)
+print(res)
25
26
"""
27
10 5
0 commit comments