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 <bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
int N, K;
cin>>N>>K;
int kada[N];
for(int i = 0; i<N; i++)
{
cin>>kada[i];
}
sort(kada, kada+N);
priority_queue<int> q;
int praeitas = kada[0];
for(int i = 1; i<N; i++)
{
q.push(kada[i] - praeitas - 1);
praeitas = kada[i];
}
int ats = kada[N-1];
for(int i = 0; i<K-1; i++)
{
ats-=q.top();
q.pop();
}
cout<<ats;
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... |