結果

問題 No.838 Noelちゃんと星々3
ユーザー irumo8202irumo8202
提出日時 2022-02-06 17:01:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 326 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 98,532 KB
最終ジャッジ日時 2023-09-02 07:01:34
合計ジャッジ時間 4,479 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
98,524 KB
testcase_01 AC 120 ms
98,532 KB
testcase_02 AC 125 ms
98,216 KB
testcase_03 AC 120 ms
98,460 KB
testcase_04 AC 119 ms
98,224 KB
testcase_05 AC 71 ms
71,300 KB
testcase_06 AC 70 ms
71,216 KB
testcase_07 AC 72 ms
71,404 KB
testcase_08 AC 70 ms
71,232 KB
testcase_09 AC 72 ms
71,352 KB
testcase_10 AC 70 ms
71,496 KB
testcase_11 AC 69 ms
71,124 KB
testcase_12 AC 70 ms
71,348 KB
testcase_13 AC 72 ms
71,216 KB
testcase_14 AC 70 ms
71,444 KB
testcase_15 AC 70 ms
71,360 KB
testcase_16 AC 70 ms
71,212 KB
testcase_17 AC 69 ms
71,296 KB
testcase_18 AC 70 ms
71,544 KB
testcase_19 AC 71 ms
71,124 KB
testcase_20 AC 72 ms
71,304 KB
testcase_21 AC 70 ms
71,464 KB
testcase_22 AC 70 ms
71,424 KB
testcase_23 AC 72 ms
71,064 KB
testcase_24 AC 70 ms
71,496 KB
testcase_25 AC 71 ms
71,320 KB
testcase_26 AC 69 ms
71,096 KB
testcase_27 AC 70 ms
71,360 KB
testcase_28 AC 70 ms
71,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Y = list(map(int, input().split()))
Y.sort()
INF = 1 << 60

D = [INF]
for i in range(N - 1):
    D.append(Y[i + 1] - Y[i])
D.append(INF)

ans = 0
p = 0
while p < N:
    if D[p] > D[p + 1]:
        ans += D[p + 1]
        p += 2
    else:
        ans += D[p]
        D[p + 1] -= D[p]
        p += 1

print(ans)
0