結果

問題 No.838 Noelちゃんと星々3
ユーザー rlangevinrlangevin
提出日時 2023-02-04 01:35:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 295 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 98,416 KB
最終ジャッジ日時 2023-09-15 22:05:29
合計ジャッジ時間 3,958 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
98,416 KB
testcase_01 AC 124 ms
98,416 KB
testcase_02 AC 120 ms
98,148 KB
testcase_03 AC 123 ms
98,344 KB
testcase_04 AC 122 ms
98,416 KB
testcase_05 AC 72 ms
71,308 KB
testcase_06 AC 70 ms
71,072 KB
testcase_07 AC 69 ms
71,384 KB
testcase_08 AC 71 ms
71,224 KB
testcase_09 AC 70 ms
71,324 KB
testcase_10 AC 70 ms
71,652 KB
testcase_11 AC 71 ms
71,464 KB
testcase_12 AC 69 ms
71,536 KB
testcase_13 AC 70 ms
71,236 KB
testcase_14 AC 71 ms
71,224 KB
testcase_15 AC 70 ms
71,472 KB
testcase_16 AC 73 ms
71,336 KB
testcase_17 AC 71 ms
71,296 KB
testcase_18 AC 70 ms
71,476 KB
testcase_19 AC 71 ms
71,200 KB
testcase_20 AC 70 ms
71,440 KB
testcase_21 AC 70 ms
71,436 KB
testcase_22 AC 71 ms
71,476 KB
testcase_23 AC 70 ms
71,288 KB
testcase_24 AC 70 ms
71,396 KB
testcase_25 AC 71 ms
71,348 KB
testcase_26 AC 73 ms
71,148 KB
testcase_27 AC 71 ms
71,080 KB
testcase_28 AC 69 ms
71,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Y = list(map(int, input().split()))
Y.sort()
E = []
N -= 1
for i in range(N):
    E.append(Y[i + 1] - Y[i])
    
inf = 10 ** 18
pre0 = 0
pre1 = inf
for i in range(N):
    dp0 = pre1
    dp1 = min(pre0, pre1) + E[i]
    pre0, dp0 = dp0, pre0
    pre1, dp1 = dp1, pre1
print(pre1)
0