結果

問題 No.838 Noelちゃんと星々3
ユーザー kohei2019kohei2019
提出日時 2023-08-13 22:35:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 252 bytes
コンパイル時間 1,507 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 96,960 KB
最終ジャッジ日時 2023-08-13 22:35:08
合計ジャッジ時間 5,691 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
96,628 KB
testcase_01 AC 128 ms
96,712 KB
testcase_02 AC 127 ms
96,960 KB
testcase_03 AC 130 ms
96,724 KB
testcase_04 AC 134 ms
96,696 KB
testcase_05 AC 72 ms
71,032 KB
testcase_06 AC 72 ms
71,240 KB
testcase_07 AC 71 ms
71,060 KB
testcase_08 AC 71 ms
71,132 KB
testcase_09 AC 70 ms
71,156 KB
testcase_10 AC 69 ms
71,300 KB
testcase_11 AC 69 ms
71,300 KB
testcase_12 AC 71 ms
71,264 KB
testcase_13 AC 70 ms
71,196 KB
testcase_14 AC 69 ms
71,068 KB
testcase_15 AC 71 ms
71,120 KB
testcase_16 AC 77 ms
71,040 KB
testcase_17 AC 72 ms
71,440 KB
testcase_18 AC 71 ms
71,316 KB
testcase_19 AC 71 ms
71,108 KB
testcase_20 AC 71 ms
71,064 KB
testcase_21 AC 71 ms
71,236 KB
testcase_22 AC 72 ms
71,400 KB
testcase_23 AC 73 ms
71,076 KB
testcase_24 AC 72 ms
71,032 KB
testcase_25 AC 70 ms
71,068 KB
testcase_26 AC 71 ms
71,244 KB
testcase_27 AC 71 ms
71,444 KB
testcase_28 AC 71 ms
71,104 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