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, vector<int>, greater<int> > pq;
int main()
{
int n, k;
cin >> n >> k;
int prev;
cin >> prev;
for(int i = 0; i < n - 1; i++)
{
int t;
cin >> t;
pq.push(t - prev);
prev = t;
}
int rez = n;
for(int i = 0; i < n - k; i++)
{
rez += pq.top() - 1; pq.pop();
}
cout << rez << endl;
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... |