Submission #542722

#TimeUsernameProblemLanguageResultExecution timeMemory
542722collodelStove (JOI18_stove)C++17
100 / 100
50 ms2252 KiB
#include <iostream> #include <queue> #include <vector> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> t(n); for(auto &x : t) { cin >> x; } priority_queue<int> pq; for(int i = 1; i < n; ++i) pq.emplace(t[i] - t[i-1] - 1); int ans = t[n-1] - t[0] + 1; k--; while(k--) { ans -= pq.top(), pq.pop(); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...