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