Submission #1185515
Source Code Expand
A,B = list(map(int,input().split())) a = list(map(int,input().split())) b = list(map(int,input().split())) # A,B = 4,3 # a = [2,4,5,4] # b = [2,8,3] # A,B = 1,3 # a = [1] # b = [2,9,9] # dp[i][j] = 左からi右からjとったときの最高点 dp = [[0 for j in range(B+1)] for i in range(A+1)] for i in range(A)[::-1]: if (B+i)%2 == 0: dp[i][B] = dp[i+1][B] + a[i] else: dp[i][B] = dp[i+1][B] for j in range(B)[::-1]: if (A+j)%2 == 0: dp[A][j] = dp[A][j+1] + b[j] else: dp[A][j] = dp[A][j+1] for i in range(A)[::-1]: for j in range(B)[::-1]: if (i+j)%2 == 0: dp[i][j] = max(dp[i+1][j]+a[i], dp[i][j+1]+b[j]) else: dp[i][j] = min(dp[i+1][j], dp[i][j+1]) print(dp[0][0]) # for i in dp: # print(i)
Submission Info
Submission Time | |
---|---|
Task | B - ゲーム |
User | chahan69 |
Language | Python (3.4.3) |
Score | 3 |
Code Size | 780 Byte |
Status | AC |
Exec Time | 798 ms |
Memory | 27844 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 3 / 3 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | AC | 17 ms | 3064 KB |
01 | AC | 547 ms | 19580 KB |
02 | AC | 798 ms | 27844 KB |
90 | AC | 17 ms | 3064 KB |
91 | AC | 17 ms | 3064 KB |