結果
| 問題 | No.615 集合に分けよう |
| コンテスト | |
| ユーザー |
Mr.Fuku
|
| 提出日時 | 2018-07-11 23:07:00 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0) |
| 結果 |
AC
|
| 実行時間 | 214 ms / 2,000 ms |
| + 146µs | |
| コード長 | 558 bytes |
| 記録 | |
| コンパイル時間 | 287 ms |
| コンパイル使用メモリ | 21,340 KB |
| 実行使用メモリ | 24,044 KB |
| 最終ジャッジ日時 | 2026-09-02 02:57:51 |
| 合計ジャッジ時間 | 6,150 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 26 |
ソースコード
# coding: utf-8
# Your code here!
n,k = map(int,input().split())
lst = list(map(int,input().split()))
lst.sort()
indx_lst = []
if n==k:
print(0)
else:
for i in range(n-1):
x = lst[i+1] - lst[i]
indx_lst.append([x,i])
indx_lst.sort()
ans_lst = []
for i in range(1,k):
ans_lst.append(indx_lst[-i][1])
ans_lst.sort()
ans_lst.append(n-1)
indx = 0
total = 0
for i in range(k):
total += lst[ans_lst[i]] - lst[indx]
indx = ans_lst[i] + 1
print(total)
Mr.Fuku