結果

問題 No.615 集合に分けよう
ユーザー ああいいああいい
提出日時 2022-03-30 19:20:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 251 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 78,608 KB
最終ジャッジ日時 2024-04-27 09:06:20
合計ジャッジ時間 3,466 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,868 KB
testcase_01 AC 38 ms
52,344 KB
testcase_02 AC 38 ms
52,932 KB
testcase_03 AC 38 ms
52,124 KB
testcase_04 AC 38 ms
53,408 KB
testcase_05 AC 41 ms
52,888 KB
testcase_06 AC 39 ms
52,132 KB
testcase_07 AC 37 ms
53,160 KB
testcase_08 AC 38 ms
53,308 KB
testcase_09 AC 38 ms
52,804 KB
testcase_10 AC 39 ms
53,356 KB
testcase_11 AC 38 ms
53,336 KB
testcase_12 AC 38 ms
53,000 KB
testcase_13 AC 39 ms
52,860 KB
testcase_14 AC 41 ms
54,576 KB
testcase_15 AC 49 ms
63,776 KB
testcase_16 AC 62 ms
71,804 KB
testcase_17 AC 73 ms
77,316 KB
testcase_18 AC 73 ms
78,248 KB
testcase_19 AC 73 ms
78,284 KB
testcase_20 AC 75 ms
78,236 KB
testcase_21 AC 74 ms
77,672 KB
testcase_22 AC 74 ms
78,608 KB
testcase_23 AC 60 ms
73,684 KB
testcase_24 AC 71 ms
77,856 KB
testcase_25 AC 44 ms
52,440 KB
testcase_26 AC 38 ms
53,108 KB
testcase_27 AC 53 ms
72,880 KB
testcase_28 AC 53 ms
72,480 KB
testcase_29 AC 57 ms
77,336 KB
testcase_30 AC 59 ms
78,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
import sys
if N == K:
    print(0)
    exit()

b = []
for i in range(N-1):
    b.append(a[i+1] - a[i])
b.sort()
ans = sum(b)
for _ in range(K-1):
    ans -= b.pop()
print(ans)
0