Submission #731340

#TimeUsernameProblemLanguageResultExecution timeMemory
731340petezaStove (JOI18_stove)C++14
100 / 100
57 ms1796 KiB
#include <bits/stdc++.h> using namespace std; int n, k, x, y, sum = 0; priority_queue<int, vector<int>, greater<int>> pq; int main() { cin >> n >> k; sum = n; cin >> x; for(int i=1;i<n;i++) { cin >> y; pq.push(y-x-1); x = y; } while(n > k) { n--; sum += pq.top(); pq.pop(); } cout << sum; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...