結果
| 問題 | No.615 集合に分けよう |
| コンテスト | |
| ユーザー |
oxyshower
|
| 提出日時 | 2020-01-11 23:27:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 519 bytes |
| 記録 | |
| コンパイル時間 | 1,658 ms |
| コンパイル使用メモリ | 172,812 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-26 08:53:54 |
| 合計ジャッジ時間 | 3,312 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 26 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
#include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;
signed main(){
int n, k; cin >> n >> k;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin >> a[i];
}
sort(a.begin(),a.end());
vector<int> v;
for(int i = 0; i < n-1; i++){
v.push_back(a[i+1] - a[i]);
}
sort(v.begin(),v.end());
int ans = 0;
for(int i = 0; i < n-1 - (k-1); i++){
ans += v[i];
}
cout << ans << endl;
return 0;
}
oxyshower