Submission #241926

#TimeUsernameProblemLanguageResultExecution timeMemory
241926GREGOIRELCStove (JOI18_stove)C++14
100 / 100
31 ms2300 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int MAX_INVITE = 1e5; int nbInvite, nbChange; int tpsArrive[MAX_INVITE]; vector<int> diff; int main() { ios::sync_with_stdio(false); cin >> nbInvite >> nbChange; for(int iInvite = 0; iInvite < nbInvite; iInvite++) { cin >> tpsArrive[iInvite]; if(iInvite > 0) { diff.push_back(tpsArrive[iInvite] - tpsArrive[iInvite - 1] - 1); } } sort(diff.begin(), diff.end()); int result = tpsArrive[nbInvite - 1] - tpsArrive[0] + 1; for(int i = nbInvite - 2; i > nbInvite - 2 - nbChange + 1; i--) { result -= diff[i]; } cout << result << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...