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;
int main() {
int sum = 0, cur1, cur2, n,k; cin >> n >> k;
vector<int> dif;
for (int i=0; i<n; i++) {
cin >> cur1;
if (i !=0) dif.push_back(cur1 - cur2 - 1);
cur2 = cur1;
}
sort(dif.begin(), dif.end());
for (int i=0; i<n-k; i++) sum += dif[i];
cout << sum + 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... |