Submission #807002

#TimeUsernameProblemLanguageResultExecution timeMemory
807002wortelwormStove (JOI18_stove)C++17
100 / 100
38 ms2032 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, matches; cin >> n >> matches; vector<int> times(n); for (int i = 0; i < n; i++) { cin >> times[i]; } int total_time = times.back() + 1 - times.front(); matches--; vector<int> diff(n - 1); for (int i = 0; i < n - 1; i++) { diff[i] = times[i + 1] - times[i] - 1; } // largest first sort(diff.rbegin(), diff.rend()); for (int i = 0; i < n - 1; i++) { if (matches == 0) { break; } matches--; total_time -= diff[i]; } cout << total_time; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...