?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
95999611 |
Practice: ya_hossein |
1195C - 18 | Python 3 | Runtime error on test 1 | 93 ms | 272 KB | 2020-10-19 18:22:36 | 2020-10-19 18:22:36 |
#besme taala #ya_hossein from types import GeneratorType def bootstrap(f, stack=[]): def wrappedfunc(*args, **kwargs): if stack: return f(*args, **kwargs) else: to = f(*args, **kwargs) while True: if type(to) is GeneratorType: stack.append(to) to = next(to) else: stack.pop() if not stack: break to = stack[-1].send(to) return to return wrappedfunc n = int(input()) num1 = list(map(int, input().split())) num0 = list(map(int, input().split())) arr1 = (n + 1)*[0] arr0 = (n + 1)*[0] @bootstrap def ans1(x): if x >= n: yield 0 if arr1[x]: yield arr1[x] arr1[x] = num1[x] + max((ans0(x + 1)), ans0(x + 2)) yield arr1[x] @bootstrap def ans0(x): if x >= n: yield 0 if arr0[x]: yield arr0[x] arr0[x] = num0[x] + max(ans1(x + 1), ans1(x + 2)) yield arr0[x] print(max(ans0(0), ans1(0)))
?
?
?
?