結果

問題 No.999 てん vs. ほむ
ユーザー yansi819
提出日時 2024-05-11 11:51:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 322 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 100,020 KB
最終ジャッジ日時 2024-12-20 08:26:35
合計ジャッジ時間 3,880 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N = int(input())
A = deque(map(int, input().split()))

a, t = 0, 0
for _ in range(N):
    if A[0] - A[1] > A[-1] - A[-2]:
        a += A[0]
        t += A[1]
        A.popleft()
        A.popleft()
    else:
        a += A[-1]
        t += A[-2]
        A.pop()
        A.pop()

print(a - t)
0