Submission #996495

#TimeUsernameProblemLanguageResultExecution timeMemory
996495toast12Stove (JOI18_stove)C++17
100 / 100
37 ms2684 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> t(n); for (int i = 0; i < n; i++) { cin >> t[i]; } t.push_back(INT_MAX); priority_queue<int> pq; for (int i = n; i > 0; i--) { pq.push(t[i]-t[i-1]-1); } int ans = n; for (int i = 0; i < k; i++) { pq.pop(); } while (!pq.empty()) { ans += pq.top(); pq.pop(); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...