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>
#define ll long long
#define ld long double
#define all(v) begin(v), end(v)
#define pi pair<int, int>
#define vi vector<int>
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, k, x, p;
vector<int> v;
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> x;
if(i > 1) v.push_back(x - p - 1);
p = x;
}
sort(v.begin(), v.end());
int res = n;
for(int i = 0; i < n-k; i++) res += v[i];
cout << res;
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... |