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;
#define int long long
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int no_of_input,matches;
int input;
vector<int> vect1;
int ans = 0;
vector<int> diff;
cin >> no_of_input >> matches;
for(int i=0;i<no_of_input;i++){
cin >> input;
vect1.push_back(input);
}
for(int i=1;i<no_of_input;i++){
diff.push_back(vect1[i]-vect1[i-1]);
}
sort(diff.begin(),diff.end());
for(int i=0;i<no_of_input-matches;i++){
ans += diff[i];
}
cout << ans+matches;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |