Submission #653039

#TimeUsernameProblemLanguageResultExecution timeMemory
653039JuanStove (JOI18_stove)C++14
100 / 100
54 ms2296 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int v[maxn]; priority_queue<int, vector<int>, greater<int>> near; int main(){ int n, k; cin >> n >> k; for(int i = 0; i < n; i++) cin >> v[i]; sort(v, v+n); for(int i = 1; i < n; i++) near.push(v[i]+1 - v[i-1]); int ans = n; k = n-k; while(k--) ans += near.top()-2, near.pop(); cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...