# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
704443 | GrandTiger1729 | Stove (JOI18_stove) | C++17 | 22 ms | 2308 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <queue>
using namespace std;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n, k; cin >> n >> k;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
priority_queue<int, vector<int>, greater<int>> pq;
for (int i = 1; i < n; i++)
pq.push(a[i] - a[i - 1] - 1);
int ans = n;
while (pq.size() >= k){
ans += pq.top();
pq.pop();
}
cout << ans << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |