Submission #536101

#TimeUsernameProblemLanguageResultExecution timeMemory
536101Spartan117Stove (JOI18_stove)C++14
100 / 100
24 ms2112 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n{}, k{}; cin >> n >> k; vector<int> timings (n); for (int i{}; i<n; i++) cin >> timings[i]; vector<int> gaps (n-1); for (int i{}; i<n-1; i++) gaps[i] = timings[i+1] - timings[i] - 1; sort(gaps.begin(), gaps.end()); int extraTime {}; for (int i{}; i<n-k; i++) extraTime += gaps[i]; cout << n+extraTime << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...