結果

問題 No.999 てん vs. ほむ
ユーザー hedwig100hedwig100
提出日時 2020-04-06 18:02:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 29,976 KB
最終ジャッジ日時 2023-09-20 19:50:40
合計ジャッジ時間 4,632 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,756 KB
testcase_01 AC 15 ms
7,780 KB
testcase_02 AC 15 ms
7,820 KB
testcase_03 AC 15 ms
7,844 KB
testcase_04 AC 15 ms
7,784 KB
testcase_05 AC 15 ms
7,916 KB
testcase_06 AC 15 ms
7,912 KB
testcase_07 AC 15 ms
7,784 KB
testcase_08 AC 19 ms
9,048 KB
testcase_09 AC 134 ms
28,132 KB
testcase_10 AC 50 ms
14,076 KB
testcase_11 AC 38 ms
12,556 KB
testcase_12 AC 67 ms
17,004 KB
testcase_13 AC 144 ms
29,848 KB
testcase_14 AC 145 ms
29,976 KB
testcase_15 AC 146 ms
29,844 KB
testcase_16 AC 144 ms
29,932 KB
testcase_17 AC 131 ms
29,292 KB
testcase_18 AC 129 ms
29,228 KB
testcase_19 AC 131 ms
29,304 KB
testcase_20 AC 131 ms
29,552 KB
testcase_21 AC 141 ms
29,668 KB
testcase_22 AC 137 ms
28,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n = int(input())
    a = list(map(int,input().split()))
    tot = sum(a)

    cuml = [0] * (n + 1)
    cumr = [0] * (n + 1)

    for i in range(n):
        cuml[i + 1] = cuml[i] + a[2 * i]
    
    for i in range(n - 1,-1,-1):
        cumr[i] = cumr[i + 1] + a[2 * i + 1]
    
    ans = 0
    for i in range(n + 1):
        ans = max(ans,2 * cuml[i] + 2 * cumr[i] - tot)
    
    print(ans)

if __name__ =='__main__':
    main()  
0