結果

問題 No.999 てん vs. ほむ
ユーザー lloyzlloyz
提出日時 2022-05-22 13:51:45
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 299 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 11,824 KB
実行使用メモリ 32,104 KB
最終ジャッジ日時 2023-10-20 16:59:40
合計ジャッジ時間 4,160 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,156 KB
testcase_01 AC 28 ms
10,156 KB
testcase_02 AC 29 ms
10,156 KB
testcase_03 AC 28 ms
10,156 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 28 ms
10,160 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 132 ms
30,412 KB
testcase_18 AC 131 ms
29,864 KB
testcase_19 AC 133 ms
30,144 KB
testcase_20 AC 136 ms
30,300 KB
testcase_21 AC 134 ms
31,780 KB
testcase_22 AC 132 ms
31,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n = int(input())
A = deque(map(int, input().split()))

ans = 0
for _ in range(n):
    if A[0] - A[1] >= A[-1] - A[-2]:
        ans += A[0] - A[1]
        A.popleft()
        A.popleft()
    else:
        ans += A[-1] - A[-2]
        A.pop()
        A.pop()
print(ans)
0