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 <vector>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n{}, k{};
cin >> n >> k;
vector<int> timings (n);
for (int i{}; i<n; i++)
cin >> timings[i];
vector<int> gaps (n-1);
for (int i{}; i<n-1; i++)
gaps[i] = timings[i+1] - timings[i] - 1;
sort(gaps.begin(), gaps.end());
int extraTime {};
for (int i{}; i<n-k; i++)
extraTime += gaps[i];
cout << n+extraTime << '\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... |