Submission #479334

#TimeUsernameProblemLanguageResultExecution timeMemory
479334Spartan117Stove (JOI18_stove)C++14
100 / 100
24 ms2320 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; bool compare (const unsigned &a, const unsigned &b) { return a>b; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); size_t n{}, k{}; cin >> n >> k; size_t availabeMatches {k-1}; vector<unsigned> guestsTimes(n); for(size_t i{}; i<n; i++) cin >> guestsTimes[i]; vector<unsigned> timeDifferences; unsigned timeDifference; for (size_t i{}; i<n-1; i++) { timeDifference = guestsTimes[i+1]-guestsTimes[i]; if (timeDifference!=1) timeDifferences.push_back(timeDifference-1); } sort(timeDifferences.begin(), timeDifferences.end(), compare); size_t burnedTime{n}; for(size_t i{availabeMatches}; i<timeDifferences.size(); i++) burnedTime+=timeDifferences[i]; cout << burnedTime << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...