結果
| 問題 |
No.615 集合に分けよう
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-19 22:30:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 419 bytes |
| コンパイル時間 | 1,838 ms |
| コンパイル使用メモリ | 173,500 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-01 23:07:28 |
| 合計ジャッジ時間 | 3,842 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 1e12;
signed main(){
lint n, K; cin >> n >> K;
vector<lint> a(n);
for(int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
vector<lint> b;
for(int i = 1; i < n; i++) b.push_back(a[i] - a[i - 1]);
sort(b.begin(), b.end());
lint ans = 0;
for(int i = 0; i < n - K; i++) ans += b[i];
cout << ans << endl;
}