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;
const int N = 2e5+5 , mod = 1e9 +7 ;
long long n , m;
int main()
{
cin>>n>>m ;
long long l = 0 , t;
vector<long long > v;
for(int i = 0 ; i<n ; i++)
{
cin>>t;
if(i)
{
v.push_back( t - l -1 );
}
l = t;
}
long long k = 0;
sort(v.begin() , v.end());
for(int i = 0;i<n - m ;i++)
k+=v[i];
cout<< n+k;
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... |