結果

問題 No.615 集合に分けよう
ユーザー NoneNone
提出日時 2021-03-13 18:19:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 177 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 82,552 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-04-23 08:51:40
合計ジャッジ時間 3,103 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,968 KB
testcase_01 AC 34 ms
51,840 KB
testcase_02 AC 35 ms
51,968 KB
testcase_03 AC 35 ms
52,352 KB
testcase_04 AC 34 ms
52,152 KB
testcase_05 AC 34 ms
51,840 KB
testcase_06 AC 34 ms
52,224 KB
testcase_07 AC 34 ms
51,968 KB
testcase_08 AC 41 ms
51,712 KB
testcase_09 AC 35 ms
51,968 KB
testcase_10 AC 35 ms
52,352 KB
testcase_11 AC 36 ms
51,968 KB
testcase_12 AC 34 ms
52,352 KB
testcase_13 AC 34 ms
52,352 KB
testcase_14 AC 35 ms
52,480 KB
testcase_15 AC 43 ms
62,336 KB
testcase_16 AC 68 ms
76,288 KB
testcase_17 AC 65 ms
76,032 KB
testcase_18 AC 65 ms
75,904 KB
testcase_19 AC 65 ms
75,776 KB
testcase_20 AC 69 ms
76,288 KB
testcase_21 AC 67 ms
77,056 KB
testcase_22 AC 69 ms
76,544 KB
testcase_23 AC 55 ms
71,936 KB
testcase_24 AC 64 ms
75,136 KB
testcase_25 AC 34 ms
51,456 KB
testcase_26 AC 35 ms
51,840 KB
testcase_27 AC 47 ms
71,296 KB
testcase_28 AC 48 ms
71,424 KB
testcase_29 AC 52 ms
75,008 KB
testcase_30 AC 52 ms
75,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
res=A[-1]-A[0]
B=[]
for i in range(N-1):
    B.append(A[i]-A[i+1])
B.sort()
res+=sum(B[:K-1])
print(res)
0