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 <queue>
using namespace std;
const int MAXN = 100004;
int n, l;
int tablica[MAXN];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> l;
for (int i = 0; n > i; i++) {
cin >> tablica[i];
}
int wynik = tablica[n - 1] - tablica[0] + 1;
l--;
priority_queue<int> kopiec;
for (int i = 1; n > i; i++) {
kopiec.push(tablica[i] - tablica[i - 1]);
}
while (l) {
wynik -= kopiec.top();
wynik++;
kopiec.pop();
l--;
}
cout << wynik;
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... |