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>
#define int long long
using namespace std;
signed main()
{
cin.tie(0);
ios_base::sync_with_stdio(false);
///
int n, k;
cin >> n >> k;
vector<int> t(n);
for (int i = 0; i < n; i++) cin >> t[i];
vector<int> gaps;
for (int i = 0; i < n - 1; i++) {
int gap = t[i + 1] - (t[i] + 1);
gaps.push_back(gap);
}
sort(gaps.begin(), gaps.end());
int total_time = n;
for (int i = 0; i < n - k; i++) {
total_time += gaps[i];
}
cout << total_time << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |