結果

問題 No.999 てん vs. ほむ
ユーザー kimiyukikimiyuki
提出日時 2020-02-28 21:44:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 34,520 KB
最終ジャッジ日時 2024-04-21 18:14:17
合計ジャッジ時間 3,437 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 32 ms
10,752 KB
testcase_05 AC 32 ms
10,752 KB
testcase_06 AC 31 ms
10,880 KB
testcase_07 AC 31 ms
10,880 KB
testcase_08 AC 36 ms
11,520 KB
testcase_09 AC 164 ms
31,712 KB
testcase_10 AC 71 ms
16,840 KB
testcase_11 AC 57 ms
15,024 KB
testcase_12 AC 90 ms
20,516 KB
testcase_13 AC 180 ms
33,540 KB
testcase_14 AC 179 ms
32,892 KB
testcase_15 AC 181 ms
32,804 KB
testcase_16 AC 182 ms
34,520 KB
testcase_17 AC 158 ms
29,860 KB
testcase_18 AC 157 ms
29,524 KB
testcase_19 AC 158 ms
29,916 KB
testcase_20 AC 160 ms
29,684 KB
testcase_21 AC 156 ms
32,652 KB
testcase_22 AC 150 ms
32,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import math
def f(a):
    dp = [None] * (len(a) // 2 + 1)
    dp[0] = 0
    for i in range(len(a) // 2):
        dp[i + 1] = dp[i] + a[2 * i] - a[2 * i + 1]
    return dp
def main():
    n = int(input())
    a = list(map(int, input().split()))
    l = f(a)
    r = list(reversed(f(list(reversed(a)))))
    print(max([l[i] + r[i] for i in range(n + 1)]))
if __name__ == "__main__":
    main()
0