結果

問題 No.838 Noelちゃんと星々3
ユーザー 👑 rin204rin204
提出日時 2022-03-24 16:18:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 229 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 98,252 KB
最終ジャッジ日時 2024-04-21 02:03:06
合計ジャッジ時間 3,095 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
97,920 KB
testcase_01 AC 116 ms
98,252 KB
testcase_02 AC 111 ms
98,036 KB
testcase_03 AC 119 ms
97,868 KB
testcase_04 AC 114 ms
97,836 KB
testcase_05 AC 39 ms
53,204 KB
testcase_06 AC 39 ms
52,724 KB
testcase_07 AC 37 ms
52,620 KB
testcase_08 AC 38 ms
53,244 KB
testcase_09 AC 37 ms
53,176 KB
testcase_10 AC 38 ms
53,036 KB
testcase_11 AC 38 ms
52,400 KB
testcase_12 AC 38 ms
53,252 KB
testcase_13 AC 38 ms
52,680 KB
testcase_14 AC 38 ms
52,252 KB
testcase_15 AC 39 ms
52,368 KB
testcase_16 AC 37 ms
52,732 KB
testcase_17 AC 38 ms
52,064 KB
testcase_18 AC 38 ms
52,396 KB
testcase_19 AC 37 ms
53,352 KB
testcase_20 AC 38 ms
52,688 KB
testcase_21 AC 38 ms
53,240 KB
testcase_22 AC 37 ms
52,572 KB
testcase_23 AC 38 ms
52,216 KB
testcase_24 AC 38 ms
53,256 KB
testcase_25 AC 38 ms
53,272 KB
testcase_26 AC 37 ms
52,876 KB
testcase_27 AC 37 ms
52,532 KB
testcase_28 AC 38 ms
52,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
A.sort()
dp = [[0] * 2 for _ in range(n)]
dp[0][0] = 1 << 60
for i in range(1, n):
    dp[i][0] = min(dp[i - 1]) + A[i] - A[i - 1]
    dp[i][1] = dp[i - 1][0]

print(dp[-1][0])
0