結果

問題 No.838 Noelちゃんと星々3
ユーザー kohei2019kohei2019
提出日時 2023-08-13 22:35:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 252 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 92,112 KB
最終ジャッジ日時 2024-05-01 12:17:06
合計ジャッジ時間 3,102 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
91,496 KB
testcase_01 AC 86 ms
92,112 KB
testcase_02 AC 84 ms
91,468 KB
testcase_03 AC 85 ms
91,172 KB
testcase_04 AC 84 ms
91,052 KB
testcase_05 AC 32 ms
51,932 KB
testcase_06 AC 32 ms
53,288 KB
testcase_07 AC 33 ms
52,360 KB
testcase_08 AC 32 ms
52,676 KB
testcase_09 AC 32 ms
53,032 KB
testcase_10 AC 33 ms
52,492 KB
testcase_11 AC 32 ms
53,784 KB
testcase_12 AC 34 ms
52,204 KB
testcase_13 AC 33 ms
52,860 KB
testcase_14 AC 32 ms
53,924 KB
testcase_15 AC 31 ms
52,740 KB
testcase_16 AC 33 ms
52,772 KB
testcase_17 AC 32 ms
52,408 KB
testcase_18 AC 32 ms
52,688 KB
testcase_19 AC 31 ms
52,816 KB
testcase_20 AC 30 ms
52,052 KB
testcase_21 AC 33 ms
53,476 KB
testcase_22 AC 32 ms
53,128 KB
testcase_23 AC 31 ms
53,140 KB
testcase_24 AC 31 ms
53,060 KB
testcase_25 AC 32 ms
53,692 KB
testcase_26 AC 30 ms
52,928 KB
testcase_27 AC 32 ms
52,444 KB
testcase_28 AC 31 ms
52,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
lsY = [-float('INF')]+list(map(int,input().split()))
lsY.sort()

dp = [[0]*(N+1) for i in range(2)]

for i in range(N):
    dp[1][i+1] = dp[0][i]
    dp[0][i+1] = min(dp[0][i]+lsY[i+1]-lsY[i],dp[1][i]+lsY[i+1]-lsY[i])

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