Submission #853158

#TimeUsernameProblemLanguageResultExecution timeMemory
853158parsadox2Stove (JOI18_stove)C++14
100 / 100
22 ms2272 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n , k , ar[N]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; k--; for(int i = 0 ; i < n ; i++) cin >> ar[i]; priority_queue <int> pq; int ans = ar[n - 1] - ar[0] + 1; for(int i = 1 ; i < n ; i++) pq.push(ar[i] - ar[i - 1] - 1); while(k--) { 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...