This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int& x : a)
cin >> x;
for (int i = 0; i < n; i++) {
if (i > 0) {
a[i - 1] = a[i] - a[i - 1] - 1;
}
}
sort(a.begin(), a.end() - 1);
ll ans = n;
for (int i = 0; i < n - k; i++) {
ans += a[i];
}
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |