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 n, k, x, y, sum = 0;
priority_queue<int, vector<int>, greater<int>> pq;
int main() {
cin >> n >> k;
sum = n;
cin >> x;
for(int i=1;i<n;i++) {
cin >> y;
pq.push(y-x-1);
x = y;
}
while(n > k) {
n--;
sum += pq.top();
pq.pop();
}
cout << sum;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |