Submission #698157

#TimeUsernameProblemLanguageResultExecution timeMemory
698157RichemStove (JOI18_stove)C++14
100 / 100
50 ms1568 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...