結果

問題 No.615 集合に分けよう
ユーザー sho_00sho_00
提出日時 2020-04-12 10:59:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 184 bytes
コンパイル時間 1,896 ms
コンパイル使用メモリ 81,496 KB
実行使用メモリ 78,476 KB
最終ジャッジ日時 2023-10-22 00:55:12
合計ジャッジ時間 4,783 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,260 KB
testcase_01 AC 40 ms
53,260 KB
testcase_02 AC 41 ms
53,260 KB
testcase_03 AC 41 ms
53,260 KB
testcase_04 AC 41 ms
53,260 KB
testcase_05 AC 42 ms
53,260 KB
testcase_06 AC 42 ms
53,260 KB
testcase_07 AC 40 ms
53,260 KB
testcase_08 AC 40 ms
53,260 KB
testcase_09 AC 40 ms
53,260 KB
testcase_10 AC 40 ms
53,260 KB
testcase_11 AC 41 ms
53,260 KB
testcase_12 AC 42 ms
53,260 KB
testcase_13 AC 42 ms
53,260 KB
testcase_14 AC 41 ms
53,260 KB
testcase_15 AC 50 ms
63,820 KB
testcase_16 AC 78 ms
78,472 KB
testcase_17 AC 76 ms
78,084 KB
testcase_18 AC 77 ms
78,084 KB
testcase_19 AC 76 ms
78,084 KB
testcase_20 AC 77 ms
78,084 KB
testcase_21 AC 77 ms
78,284 KB
testcase_22 AC 77 ms
78,476 KB
testcase_23 AC 63 ms
74,536 KB
testcase_24 AC 77 ms
77,700 KB
testcase_25 AC 41 ms
53,264 KB
testcase_26 AC 41 ms
53,264 KB
testcase_27 AC 55 ms
72,012 KB
testcase_28 AC 56 ms
72,012 KB
testcase_29 AC 60 ms
75,716 KB
testcase_30 AC 62 ms
77,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=[]
for i in range(N-1):
  l.append(a[i+1]-a[i])
l=sorted(l,reverse=True)
tmp=sum(l[0:K-1])
print(a[-1]-tmp-a[0])
0