結果

問題 No.838 Noelちゃんと星々3
ユーザー R ITSUMIR ITSUMI
提出日時 2020-06-22 22:06:12
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 230 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 94,716 KB
最終ジャッジ日時 2023-09-16 19:29:41
合計ジャッジ時間 3,869 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
94,488 KB
testcase_01 AC 117 ms
94,716 KB
testcase_02 AC 114 ms
94,484 KB
testcase_03 AC 114 ms
94,512 KB
testcase_04 AC 114 ms
94,480 KB
testcase_05 AC 69 ms
71,152 KB
testcase_06 AC 67 ms
71,144 KB
testcase_07 AC 66 ms
71,132 KB
testcase_08 AC 68 ms
71,456 KB
testcase_09 AC 66 ms
71,312 KB
testcase_10 AC 67 ms
71,596 KB
testcase_11 AC 68 ms
71,136 KB
testcase_12 AC 69 ms
71,272 KB
testcase_13 AC 68 ms
71,176 KB
testcase_14 AC 69 ms
71,280 KB
testcase_15 AC 70 ms
71,140 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 68 ms
71,264 KB
testcase_19 AC 68 ms
71,308 KB
testcase_20 AC 68 ms
71,456 KB
testcase_21 AC 69 ms
71,184 KB
testcase_22 AC 68 ms
71,144 KB
testcase_23 AC 64 ms
71,396 KB
testcase_24 AC 66 ms
71,536 KB
testcase_25 AC 68 ms
71,308 KB
testcase_26 AC 69 ms
71,268 KB
testcase_27 AC 66 ms
71,344 KB
testcase_28 AC 68 ms
71,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Y = sorted(list(map(int, input().split())))
dp = [float('inf')]*N
dp[1], dp[2] = abs(Y[0]-Y[1]), abs(Y[0]-Y[2])
for i in range(3,N):
    dp[i] = min(dp[i-3]+abs(Y[i]-Y[i-2]),dp[i-2]+abs(Y[i]-Y[i-1]))
print(dp[-1])
0