結果

問題 No.2196 Pair Bonus
ユーザー flygonflygon
提出日時 2023-01-20 21:40:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 141,424 KB
最終ジャッジ日時 2023-09-05 13:54:06
合計ジャッジ時間 4,271 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,408 KB
testcase_01 AC 73 ms
71,388 KB
testcase_02 AC 74 ms
71,468 KB
testcase_03 AC 253 ms
137,560 KB
testcase_04 AC 250 ms
137,716 KB
testcase_05 AC 84 ms
76,752 KB
testcase_06 AC 79 ms
76,144 KB
testcase_07 AC 84 ms
76,828 KB
testcase_08 AC 118 ms
85,712 KB
testcase_09 AC 242 ms
141,424 KB
testcase_10 AC 190 ms
117,864 KB
testcase_11 AC 127 ms
88,092 KB
testcase_12 AC 212 ms
117,448 KB
testcase_13 AC 84 ms
76,868 KB
testcase_14 AC 102 ms
80,628 KB
testcase_15 AC 85 ms
76,664 KB
testcase_16 AC 232 ms
128,208 KB
testcase_17 AC 90 ms
76,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))

dp = [[0,0] for i in range(2*n)]
dp[0] = [a[0],b[0]]
for i in range(1, 2*n):
  ai,bi = a[i], b[i]
  if i % 2 == 1:
    xi,yi = x[i//2], y[i//2]
    dp[i][0] = max(dp[i-1][0] + ai + xi, dp[i-1][1] + ai + yi)
    dp[i][1] = max(dp[i-1][0] + bi + yi, dp[i-1][1] + bi + xi)
  else:
    dp[i][0] = max(dp[i-1]) + ai
    dp[i][1] = max(dp[i-1]) + bi
  
print(max(dp[-1]))
0