Submission #1292442

#TimeUsernameProblemLanguageResultExecution timeMemory
1292442olympolympStove (JOI18_stove)C++20
100 / 100
15 ms1488 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int ali, gs; cin >> ali >> gs; vector<int> bjk(ali); for (int i = 0; i < ali; i++) { cin >> bjk[i]; } long long sivas = bjk[ali - 1] - bjk[0] + 1; vector<int> ts; for (int i = 0; i < ali - 1; i++) { ts.push_back(bjk[i + 1] - bjk[i] - 1); } sort(ts.rbegin(), ts.rend()); for (int i = 0; i < gs - 1 && i < ts.size(); i++) { sivas -= ts[i]; } cout << sivas << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...