#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cstring>
#include <bitset>
using namespace std;
#define int long long int
#define mod 1000000007
#define endl '\n'
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,k; cin >> n >> k;
vector<int> ans;
int prev; cin >> prev;
for (int i = 1; i < n; i++){
int a; cin >> a;
ans.push_back(a-prev);
}
int anss = 0;
sort(ans.begin(), ans.end());
for (int i = 0; i < n-k; i++){
ans[i]--;
anss += ans[i];
}
cout << anss+n << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |