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()
{
int a,b;
cin >> a >> b;
vector <int> v;
for(int i = 0 ; i < a; i++){
int k;
cin >> k;
v.push_back(k);
}
vector <int> it;
for(int i = 1 ; i < a ; i++){
int h = 0 ;
h = v[i] - v[i - 1];
it.push_back(h);
}
sort(it.rbegin() , it.rend());
int t;
t = v[a- 1] - v[0] + 1;
for(int i = 0 ; i < b - 1; i++){
t = t - (it[i] - 1);
}
cout << t;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |