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<iostream>
#include<queue>
using namespace std;
using ull = unsigned long long;
int main()
{
int n,k,last,x; cin >> n >> k >> last; ull ans = last; k--;
priority_queue<int> pq;
for(int i = 2; i <= n ; i++)
{
cin >> x; pq.push(x - last - 1);
last = x;
}
ans = last - ans + 1;
while(!pq.empty() && k)
{
ans -= pq.top();
pq.pop(); k--;
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |