#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n, k, x, prev, sum=0;
cin >> n >> k >> prev;
vector<int> v;
for (int i=1; i<n; i++){
cin >> x;
sum += x-prev;
v.push_back(x-prev);
prev=x;
}
sort(v.begin(), v.end(), greater<int>());
for (int i=0; i<k-1; i++){
sum-=v[i];
sum++;
}
cout << sum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |