結果

問題 No.999 てん vs. ほむ
ユーザー O2MTO2MT
提出日時 2020-12-15 00:41:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 282 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 81,740 KB
実行使用メモリ 104,508 KB
最終ジャッジ日時 2023-10-20 05:26:19
合計ジャッジ時間 4,007 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,432 KB
testcase_01 AC 40 ms
53,432 KB
testcase_02 AC 40 ms
53,432 KB
testcase_03 AC 40 ms
53,432 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 40 ms
53,432 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 94 ms
104,292 KB
testcase_18 AC 92 ms
104,508 KB
testcase_19 AC 93 ms
104,292 KB
testcase_20 AC 93 ms
104,304 KB
testcase_21 AC 106 ms
99,108 KB
testcase_22 AC 105 ms
98,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N = int(input())
A = list(map(int,input().split()))
if N == 1:
    print(max(A)-min(A))
    exit()

A = deque(A)
ans = 0
while A:
    if A[0]-A[1] > A[-1]-A[-2]:
        ans += A.popleft()-A.popleft()
    else:
        ans += A.pop()-A.pop()
print(ans)
0