結果

問題 No.838 Noelちゃんと星々3
ユーザー 👑 H20H20
提出日時 2021-11-24 14:05:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 228 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 86,800 KB
実行使用メモリ 92,232 KB
最終ジャッジ日時 2023-09-09 05:42:08
合計ジャッジ時間 5,005 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
92,128 KB
testcase_01 AC 117 ms
92,232 KB
testcase_02 AC 116 ms
92,124 KB
testcase_03 AC 117 ms
92,080 KB
testcase_04 AC 118 ms
92,072 KB
testcase_05 AC 70 ms
71,496 KB
testcase_06 AC 71 ms
71,496 KB
testcase_07 AC 70 ms
70,960 KB
testcase_08 AC 71 ms
71,224 KB
testcase_09 AC 72 ms
71,176 KB
testcase_10 AC 71 ms
71,360 KB
testcase_11 AC 71 ms
71,488 KB
testcase_12 AC 71 ms
71,208 KB
testcase_13 AC 73 ms
71,176 KB
testcase_14 AC 72 ms
71,244 KB
testcase_15 AC 70 ms
71,220 KB
testcase_16 AC 71 ms
71,264 KB
testcase_17 AC 72 ms
71,180 KB
testcase_18 AC 71 ms
71,488 KB
testcase_19 AC 71 ms
71,064 KB
testcase_20 AC 70 ms
71,184 KB
testcase_21 AC 72 ms
71,264 KB
testcase_22 AC 72 ms
70,968 KB
testcase_23 AC 71 ms
71,272 KB
testcase_24 AC 71 ms
71,176 KB
testcase_25 AC 72 ms
70,972 KB
testcase_26 AC 72 ms
71,264 KB
testcase_27 AC 73 ms
71,104 KB
testcase_28 AC 72 ms
71,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Y = list(map(int,input().split()))
Y.sort()
dp0 = 10**10
dp1 = 0
last = Y[0]
for i in range(1,N):
    temp = dp0
    dp0 = min(dp1 + abs(Y[i]-last),dp0 + abs(Y[i]-last))
    dp1 = temp
    last = Y[i]
print(dp0)
0