結果

問題 No.999 てん vs. ほむ
ユーザー maguchi_p_qmaguchi_p_q
提出日時 2020-02-28 21:34:50
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 10,628 KB
実行使用メモリ 29,956 KB
最終ジャッジ日時 2023-08-03 19:46:10
合計ジャッジ時間 3,410 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,160 KB
testcase_01 AC 16 ms
8,184 KB
testcase_02 AC 15 ms
8,068 KB
testcase_03 AC 16 ms
8,180 KB
testcase_04 AC 16 ms
8,164 KB
testcase_05 AC 16 ms
8,012 KB
testcase_06 AC 15 ms
8,068 KB
testcase_07 AC 16 ms
8,068 KB
testcase_08 AC 20 ms
8,844 KB
testcase_09 AC 143 ms
28,324 KB
testcase_10 AC 54 ms
14,052 KB
testcase_11 AC 40 ms
12,260 KB
testcase_12 AC 71 ms
17,100 KB
testcase_13 AC 158 ms
29,848 KB
testcase_14 AC 156 ms
29,852 KB
testcase_15 AC 161 ms
29,956 KB
testcase_16 AC 159 ms
29,808 KB
testcase_17 AC 139 ms
29,340 KB
testcase_18 AC 137 ms
29,084 KB
testcase_19 AC 141 ms
29,344 KB
testcase_20 AC 139 ms
29,460 KB
testcase_21 AC 138 ms
29,792 KB
testcase_22 AC 136 ms
29,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate

N = int(input())
A = [int(zz) for zz in input().split()]

A = [A[2*i]-A[2*i+1] for i in range(N)]

li_left = [0] + list(accumulate(A))
li_right = list(accumulate(A[::-1]))[::-1] + [0]

ans = 0
for i in range(N+1):
    ans = max(ans,li_left[i]-li_right[i])

print(ans)
0