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;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
const ll maxint=2e18;
const ll minint =-2e18;
/*******\
(͡ ° ͜ʖ ͡ °): Hi, relax.
\* */
int main(){
int n,k,f;
cin>>n>>k>>f;
vector<int> v;
for(int i=1;i<n;i++){
int x;
cin>>x;
v.push_back(x-f-1);
f=x;
}
sort(v.begin(),v.end());
int res = n;
for(int i=0;i<n-k;i++){
res += v[i];
}
cout<<res<<'\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... |