#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |