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;
typedef long long ll;
int main() {
int n,k; cin >> n >> k;
ll ans=n;
priority_queue<ll,vector<ll>,greater<ll>> p;
int last; cin >> last;
for(int i=1;i<n;i++) {
int t; cin >> t;
p.push(t-last-1);
last=t;
}
int sus=n-k;
while(sus--){
ans+= p.top();
p.pop();
}
cout << ans;
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... |