結果
| 問題 |
No.615 集合に分けよう
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-30 19:20:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 75 ms / 2,000 ms |
| コード長 | 251 bytes |
| コンパイル時間 | 245 ms |
| コンパイル使用メモリ | 82,024 KB |
| 実行使用メモリ | 77,952 KB |
| 最終ジャッジ日時 | 2024-11-15 09:57:52 |
| 合計ジャッジ時間 | 3,741 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 26 |
ソースコード
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)