結果

問題 No.615 集合に分けよう
ユーザー tktk_snsntktk_snsn
提出日時 2021-08-08 20:43:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 336 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 81,880 KB
最終ジャッジ日時 2023-10-19 21:21:27
合計ジャッジ時間 5,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,548 KB
testcase_01 AC 36 ms
53,548 KB
testcase_02 AC 41 ms
53,548 KB
testcase_03 AC 37 ms
53,548 KB
testcase_04 AC 40 ms
53,548 KB
testcase_05 AC 41 ms
53,548 KB
testcase_06 AC 40 ms
53,548 KB
testcase_07 AC 38 ms
53,548 KB
testcase_08 AC 37 ms
53,548 KB
testcase_09 AC 37 ms
53,548 KB
testcase_10 AC 36 ms
53,548 KB
testcase_11 AC 38 ms
53,548 KB
testcase_12 AC 41 ms
53,548 KB
testcase_13 AC 45 ms
59,796 KB
testcase_14 AC 45 ms
61,844 KB
testcase_15 AC 45 ms
62,008 KB
testcase_16 AC 68 ms
75,072 KB
testcase_17 AC 60 ms
73,224 KB
testcase_18 AC 71 ms
75,564 KB
testcase_19 AC 125 ms
75,572 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
A = sorted(map(int, input().split()))

m = n - k + 1
dp = [0] * m
for i in range(m):
    dp[i] = A[i] - A[0]

for i in range(1, k):
    for j in range(m):
        dp[j] -= A[i+j]
    for j in range(1, m):
        dp[j] = min(dp[j], dp[j-1])
    for j in range(m):
        dp[j] += A[i+j]

print(dp[m-1])
0