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, k, S;
cin >> n >> k;
int T[n];
vector <int> V;
for (int i = 0; i < n; i++)
{
cin >> T[i];
if (i != 0)
{
V.push_back(T[i]-T[i-1]-1);
}
}
sort(V.rbegin(),V.rend());
S = T[n-1] - T[0] + 1;
for (int i = 0; i < k-1; i++)
{
S -= V[i];
}
cout << S;
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... |