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<iostream>
#include<algorithm>
using namespace std;
long long n,k,in[100005],pr,a,r;
int main()
{
cin>>n>>k;k--;
cin>>pr;
r-=(pr-1);
for(int i=1;i<n;i++)
{
cin>>a;
in[i-1]=a-pr-1;
pr=a;
}
r+=pr;
sort(in,in+n);
for(int i=n-1;i>=n-k;i--)
{
r-=in[i];
}
cout<<r<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |