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 <algorithm>
#include <vector>
using namespace std;
int main()
{
int n,k,pop,akt;
cin >> n >> k;
vector<int> odl;
cin >> pop >> akt;
odl.push_back(akt-pop-1);
for (int i=0; i<n-2; i++){
pop=akt;
cin >> akt;
odl.push_back(akt-pop-1);
}
sort(odl.begin(),odl.end());
reverse(odl.begin(),odl.end());
//for (int i:odl) cout << i << ' ';
k=n-k;
int wyn=n;
while (k-- or (odl.size() and odl[odl.size()]<0)){
wyn+=odl[odl.size()-1];
odl.pop_back();
}
cout << wyn;
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... |