This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///
/// You fell for it, fool!
/// Thunder Cross Split Attack!
///
#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
typedef long long ll;
using namespace std;
const int N = 100'010;
int t[N], u[N];
int n, k;
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin >> n >> k; --k;
Loop(i,0,n) cin >> t[i];
Loop(i,0,n-1) u[i] = t[i+1]-t[i]-1;
sort(u,u+n-1,greater<int>());
int ans = t[n-1]-t[0]+1;
Loop(i,0,k) ans -= u[i];
cout << ans << '\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... |