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 int
#define ff first
#define ss second
#define FT ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
vector <int> diff;
const int maxn = 1e5 + 10;
int t[maxn];
signed main()
{
FT;
int n , k;
cin >> n >> k;
for (int i = 1 ; i <= n ; i++)
{
cin >> t[i];
}
for (int i = 2 ; i <= n ; i++)
{
diff.push_back(t[i] - (t[i - 1] + 1));
}
sort (diff.begin() , diff.end());
int ans = n;
for (int i = 0 ; i < n - k ; i++)
{
ans += diff[i];
}
cout << ans << endl;
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... |