Submission #1115228

#TimeUsernameProblemLanguageResultExecution timeMemory
1115228staszic_ojuzStove (JOI18_stove)C++17
100 / 100
34 ms1464 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n, za; cin >> n >> za; vector<int> kiedy(n); vector<int> roz; za -= 1; for (int i = 0; i < n; i++) { cin >> kiedy[i]; if (i > 0) { roz.push_back(kiedy[i] - kiedy[i - 1] - 1); } } int calosc = kiedy[kiedy.size() - 1] + 1 - kiedy[0]; sort(roz.begin(), roz.end()); while (za > 0 and roz.size() > 0) { calosc -= roz[roz.size() - 1]; roz.pop_back(); za -= 1; } cout << calosc; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...