Submission #765904

#TimeUsernameProblemLanguageResultExecution timeMemory
765904yusuf12360Stove (JOI18_stove)C++14
100 / 100
24 ms2320 KiB
#include<bits/stdc++.h> #define int long long using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, a, b, k, ans; cin >> n >> k >> a; ans=n; priority_queue<int, vector<int>, greater<int>> pq; for(int i=1; i<n; i++) b=a, cin >> a, pq.push(a-b); while((k++)<n) ans+=pq.top()-1, 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...