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()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
set < long long > st;
long long n,k,a;
cin>>n>>k;
for(long long i=1;i<=n;i++)
{
cin>>a;
st.insert(a);
}
long long res=st.size();
vector < long long > vid;
long long mun=-1;
for(auto u:st)
{
if(mun!=-1)
{
vid.push_back(u-(mun+1));
}
mun=u;
}
sort(vid.begin(),vid.end());
long long ndob=st.size()-k;
for(long long i=0;i<ndob;i++)
{
res+=vid[i];
}
cout<<res<<"\n";
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... |