Submission #1124827

#TimeUsernameProblemLanguageResultExecution timeMemory
1124827jjjwongStove (JOI18_stove)C++20
100 / 100
16 ms1096 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N, K; cin >> N >> K; int matches_left = K-1; int T[N]; int difference[N]; for (int i=0; i<N; i++) { cin >> T[i]; if (i>0) difference[i] = T[i] - T[i-1] - 1; else difference[i] = 0; } sort(difference, difference+N); int total_time = T[N-1] - T[0] + 1; for (int i=1; i<matches_left+1; i++) { total_time -= max(0, difference[N-i]); } cout << total_time; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...