Submission #1033581

#TimeUsernameProblemLanguageResultExecution timeMemory
1033581coin_Stove (JOI18_stove)C++14
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main(){ cin.tie(nullptr) -> sync_with_stdio(0); int n, k; cin >> n >> k; priority_queue<int> pq; vector<int> t(n+5); for (int i = 1; i <= n; i++){ cin >> t[i]; } for (int i = 2; i <= n; i++){ pq.push(t[i] - t[i-1] - 1); } k--; int ans = t[n]; while(!pq.empty() && k){ ans -= pq.top(); pq.pop(); k--; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...