結果

問題 No.999 てん vs. ほむ
ユーザー GrayCoder
提出日時 2020-02-28 21:45:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 404 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 37,788 KB
最終ジャッジ日時 2024-10-13 17:11:45
合計ジャッジ時間 4,289 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 4 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = list(map(int, input().split()))

    a = A[:]
    ans = 0
    for _ in [0] * N:
        case1 = a[0] - a[1]
        case2 = a[-1] - a[-2]
        if case1 > case2:
            ans += case1
            a = a[2:]
        else:
            ans += case2
            a = a[:-2]
    print(ans)


main()
0