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 <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 1e5;
int a[MAX_N + 1];
int n, k;
int main() {
int ant;
cin >> n >> k >> ant;
for (int i = 2; i <= n; i++) {
int x;
cin >> x;
a[i - 1] = x - ant - 1;
ant = x;
}
sort(a + 1, a + n);
int answer = 0;
for (int i = 1; i <= n - k; i++) {
answer += a[i];
}
cout << answer + 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... |