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;
priority_queue<int> pq;
int wej[100003];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,k,st;
cin >> n >> k;
for (int i = 1; i<=n; i++){
cin >> wej[i];
}
st=wej[n]-wej[1]+1;
for (int i = 2; i<=n; i++){
pq.push(wej[i]-wej[i-1]-1);
}
for (int i = 1; (i<=k-1) && pq.size(); i++){
st-=pq.top();
pq.pop();
}
cout << st << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |