結果

問題 No.999 てん vs. ほむ
ユーザー ntk-ta01ntk-ta01
提出日時 2020-02-28 21:44:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 33,392 KB
最終ジャッジ日時 2024-04-21 18:14:01
合計ジャッジ時間 3,634 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 AC 34 ms
10,752 KB
testcase_07 AC 31 ms
10,752 KB
testcase_08 AC 36 ms
11,520 KB
testcase_09 AC 159 ms
31,228 KB
testcase_10 AC 69 ms
16,664 KB
testcase_11 AC 56 ms
14,788 KB
testcase_12 AC 87 ms
19,684 KB
testcase_13 AC 177 ms
33,264 KB
testcase_14 AC 173 ms
33,392 KB
testcase_15 AC 175 ms
33,392 KB
testcase_16 AC 173 ms
33,264 KB
testcase_17 AC 154 ms
29,148 KB
testcase_18 AC 152 ms
28,944 KB
testcase_19 AC 153 ms
29,220 KB
testcase_20 AC 151 ms
28,868 KB
testcase_21 AC 145 ms
32,488 KB
testcase_22 AC 143 ms
31,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [A[i] - A[i+1] for i in range(0, 2*N, 2)]
    # print(B)
    from itertools import accumulate
    S = [a for a in accumulate([0] + B)]
    # print(S)
    ans = -(10**9)
    for i in range(N+1):
        ans = max(ans, S[i] - S[0] - (S[N] - S[i]))
    print(ans)


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