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 <set>
int main()
{
int n, k;
std::cin >> n >> k;
int a[100010];
std::multiset<int> seti;
long long ans = n;
for (int i = 0; i < n; ++i)
{
std::cin >> a[i];
if (i > 0)
seti.insert(a[i] - a[i - 1] - 1);
}
int cnt = 0;
int maxi = n - k;
for (auto it : seti)
{
int val = it;
if (cnt >= maxi)
break;
else
{
ans += val;
++cnt;
}
}
std::cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |