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>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,k;
cin >> n >> k;
int a[n];
for (int i = 0;i < n;i++){
cin >> a[i];
}
vector <int> b;
for (int i = 0;i+1 < n;i++){
b.push_back(a[i+1]-a[i]);
}
int p = 0;
sort(b.begin(),b.end());
for (int i = 0;i < n-k;i++){
p += b[i];
}
cout << p+k << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |