Submission #5117961


Source Code Expand

from functools import lru_cache
import sys
sys.setrecursionlimit(1000000)

A, B = map(int, input().split())
X = [int(a) for a in input().split()]
Y = [int(a) for a in input().split()]

@lru_cache(maxsize=None)
def calc(a, b):
    if a == A and b == B:
        return 0
    if (a+b) % 2 == 0:
        ret = 0
        if a < A:
            ret = max(ret, X[a] + calc(a + 1, b))
        if b < B:
            ret = max(ret, Y[b] + calc(a, b + 1))
        return ret
    else:
        ret = 10 ** 100
        if a < A:
            ret = min(ret, calc(a + 1, b))
        if b < B:
            ret = min(ret, calc(a, b + 1))
        return ret

print(calc(0, 0))

Submission Info

Submission Time
Task B - ゲーム
User Kiri8128
Language PyPy3 (2.4.0)
Score 3
Code Size 683 Byte
Status AC
Exec Time 1479 ms
Memory 160636 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 AC 183 ms 39024 KB
01 AC 1005 ms 133084 KB
02 AC 1479 ms 160636 KB
90 AC 177 ms 38256 KB
91 AC 181 ms 38256 KB