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;
cin>>n>>k;
int arr[n],arr1[n-1];
for(int i=0; i<n; ++i)
{
cin>>arr[i];
if(i)
arr1[i-1]=arr[i]-arr[i-1]-1;
}
sort(arr1,arr1+n-1);
int ans=n;
for(int i=0; i<n-k; ++i)
ans+=arr1[i];
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |