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>
using namespace std;
const int MAX_GUEST = 1e5+42;
int nbGuest, nbSwitch;
int ecart[MAX_GUEST];
int total = 0;
int main() {
cin >> nbGuest >> nbSwitch;
int preced = 0;
for(int cur = 0; cur < nbGuest; cur++) {
int depart;
cin >> depart;
if(cur > 0) {
ecart[cur-1] = preced - depart;
}
else {
total = -depart;
}
preced = depart+1;
}
total += preced;
sort(ecart, ecart + nbGuest-1);
for(int trou = 0; trou < nbSwitch-1; trou++) {
total += ecart[trou];
}
cout << total;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |