Contest Duration: ~ (local time) (300 minutes) Back to Home

Submission #17504018

Source Code Expand

Copy
```A, B = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
INF = float('inf')
# DP配列
# dp[i][j]: 左にi、右にj個の物が積まれているときのすぬけ君の合計
dp = [[INF]*(B+1) for _ in range(A+1)]

for i in range(A+1):
for j in range(B+1):
if (i, j) == (0, 0):
dp[0][0] = 0
elif i == 0:
if (A+B-i-j)%2 == 0:
dp[0][j] = dp[0][j-1]+b[B-j]
else:
dp[0][j] = dp[0][j-1]
elif j == 0:
if (A+B-i-j)%2 == 0:
dp[i][0] = dp[i-1][0]+a[A-i]
else:
dp[i][0] = dp[i-1][0]
else:
if (A+B-i-j)%2 == 0:
# すぬけ君は最大にしようとする
dp[i][j] = max(dp[i-1][j]+a[A-i], dp[i][j-1]+b[B-j])
else:
# すめけ君は最小にしようとする
dp[i][j] = min(dp[i-1][j], dp[i][j-1])
print(dp[A][B])
```

#### Submission Info

Submission Time 2020-10-18 18:42:11+0900 B - ゲーム puredore Python (3.8.2) 3 1032 Byte AC 765 ms 32360 KB

#### Judge Result

Set Name All
Score / Max Score 3 / 3
Status
 AC × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 29 ms 9136 KB
01 577 ms 25264 KB
02 765 ms 32360 KB
90 20 ms 9064 KB
91 20 ms 9028 KB