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;
using i64 = int64_t;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
i64 N, K;
cin >> N >> K;
vector<i64> bet(N - 1);
vector<i64> guests(N);
for (i64 i = 0; i < N; i++)
{
cin >> guests[i];
if (i > 0)
{
bet[i - 1] = guests[i] - guests[i - 1] - 1;
}
}
sort(bet.rbegin(), bet.rend());
i64 wynik = guests[N - 1] - guests[0] + 1;
for (i64 i = 1; i < K; i++)
{
wynik -= bet[i - 1];
}
cout << wynik << "\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... |