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 n, za;
cin >> n >> za;
vector<int> kiedy(n);
vector<int> roz;
za -= 1;
for (int i = 0; i < n; i++) {
cin >> kiedy[i];
if (i > 0) {
roz.push_back(kiedy[i] - kiedy[i - 1] - 1);
}
}
int calosc = kiedy[kiedy.size() - 1] + 1 - kiedy[0];
sort(roz.begin(), roz.end());
while (za > 0 and roz.size() > 0) {
calosc -= roz[roz.size() - 1];
roz.pop_back();
za -= 1;
}
cout << calosc;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |