結果

問題 No.999 てん vs. ほむ
ユーザー OhnumaOhnuma
提出日時 2020-04-07 15:09:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 51,328 KB
最終ジャッジ日時 2023-09-21 19:58:15
合計ジャッジ時間 7,482 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
29,584 KB
testcase_01 AC 129 ms
29,560 KB
testcase_02 AC 128 ms
29,688 KB
testcase_03 AC 129 ms
29,672 KB
testcase_04 AC 129 ms
29,592 KB
testcase_05 AC 129 ms
29,620 KB
testcase_06 AC 129 ms
29,644 KB
testcase_07 AC 129 ms
29,576 KB
testcase_08 AC 135 ms
30,364 KB
testcase_09 AC 303 ms
49,844 KB
testcase_10 AC 181 ms
35,468 KB
testcase_11 AC 162 ms
33,884 KB
testcase_12 AC 206 ms
38,272 KB
testcase_13 AC 311 ms
51,104 KB
testcase_14 AC 316 ms
51,316 KB
testcase_15 AC 317 ms
51,280 KB
testcase_16 AC 312 ms
51,288 KB
testcase_17 AC 309 ms
50,472 KB
testcase_18 AC 293 ms
50,448 KB
testcase_19 AC 305 ms
50,616 KB
testcase_20 AC 299 ms
50,876 KB
testcase_21 AC 319 ms
51,328 KB
testcase_22 AC 313 ms
50,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
n = int(input())
A = list(map(int,input().split()))
L = [a for a in A[::2]]
R = [a for a in A[1::2]]
cumL = np.cumsum(L)
cumR = np.cumsum(R)
sumA = sum(A)
ans = 0
ans = max(cumL[-1], cumR[-1])*2 - sumA
for i in range(n):
    h = cumL[i] + cumR[-1] - cumR[i]
    t = sumA - h
    ans = max(ans, h-t)
print(ans)
0