結果

問題 No.999 てん vs. ほむ
ユーザー AzumabashiAzumabashi
提出日時 2020-04-23 14:16:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 421 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 32,656 KB
最終ジャッジ日時 2024-04-21 14:30:06
合計ジャッジ時間 3,504 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,624 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 30 ms
10,624 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 31 ms
10,880 KB
testcase_07 AC 31 ms
10,752 KB
testcase_08 AC 35 ms
11,520 KB
testcase_09 AC 171 ms
30,824 KB
testcase_10 AC 72 ms
16,668 KB
testcase_11 AC 58 ms
14,632 KB
testcase_12 AC 92 ms
19,560 KB
testcase_13 AC 188 ms
32,648 KB
testcase_14 AC 185 ms
32,496 KB
testcase_15 AC 185 ms
32,656 KB
testcase_16 AC 184 ms
32,480 KB
testcase_17 AC 162 ms
29,020 KB
testcase_18 AC 158 ms
28,704 KB
testcase_19 AC 161 ms
28,992 KB
testcase_20 AC 162 ms
29,152 KB
testcase_21 AC 156 ms
32,616 KB
testcase_22 AC 155 ms
31,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    length = int(input())
    numbers = [int(x) for x in input().split()]
    diff = [0 for _ in range(length)]
    for i in range(length):
        diff[i] = numbers[2 * i + 1] - numbers[2 * i]
        if i > 0:
            diff[i] += diff[i - 1]
    answer = diff[-1]
    for i in range(length):
        answer = max(answer, diff[-1] - 2 * diff[i])
    print(answer)


if __name__ == '__main__':
    main()

0