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>
#define ll long long
using namespace std;
const ll mod = 1e9+7;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n,k;
cin >> n >> k;
vector<ll>a(n),b;
for(ll i=0;i<n;i++) cin >> a[i];
for(ll i=1;i<n;i++) b.push_back(a[i]-a[i-1]);
if(k>=n)
{
cout << n;
return 0;
}
if(k==1)
{
cout << a[n-1]+1-a[0];
return 0;
}
ll R=k;
ll treba=n-k;
sort(b.begin(),b.end());
for(ll i=0;i<treba;i++)
{
R+=b[i];
cout << b[i] << endl;
}
cout << R;
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... |