//Stove(Vjudge)
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, k, cnt = 0;
cin >> n >> k;
k--;
int t[n + 10], dist[n + 10];
for(int i = 0; i < n; i++){
cin >> t[i];
}
t[0]++;
for(int i = 0; i < n - 1; i++){
dist[i] = t[i + 1] - t[i];
t[i + 1]++;
//cout << dist[i] << endl;
}
sort(dist , dist + n);
for(int i = n - 2; i >= n - k - 1; i--){
cnt += dist[i];
}
//cout << t[n - 1] << endl;
cout << t[n - 1] - cnt - 1 << endl;
//cout << cnt << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |