Submission #366224

#TimeUsernameProblemLanguageResultExecution timeMemory
366224Tuk1352Stove (JOI18_stove)C++11
100 / 100
61 ms2276 KiB
#include <bits/stdc++.h> using namespace std; int main () { int n, k, S; cin >> n >> k; int T[n]; vector <int> V; for (int i = 0; i < n; i++) { cin >> T[i]; if (i != 0) { V.push_back(T[i]-T[i-1]-1); } } sort(V.rbegin(),V.rend()); S = T[n-1] - T[0] + 1; for (int i = 0; i < k-1; i++) { S -= V[i]; } cout << S; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...