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 long long mod=998244353;
long long n,k;
multiset<long long>ms;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>n>>k;
int a,b;
cin>>b;
for(int i=0;i<n-1;i++)
{
cin>>a;
ms.insert(a-b+1);
b=a+1;
}
long long ans=0;
for(int i=0;i<n-k;i++)
{
ans+=*ms.begin();
ms.erase(ms.begin());
}
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... |