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;
//#define int long long;
const int maxn = 1e5 + 10;
int n, k, t[maxn], d[maxn];
int32_t main()
{
ios::sync_with_stdio(false), cin.tie(nullptr);
cin >> n >> k;
for(int i = 0; i < n; i++)
{
cin >> t[i];
if(i) d[i] = t[i] - t[i - 1] - 1;
}
int ans = 0;
sort(d + 1, d + n);
for(int i = 0; i < n - k; i++)
{
ans += d[i + 1];
}
cout << ans + n << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |