# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
557002 | Ai7081 | Stove (JOI18_stove) | C++17 | 27 ms | 2256 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 <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
priority_queue<int> pq;
int n, k, a[N], ans;
int main() {
scanf(" %d %d", &n, &k);
for (int i=0; i<n; i++) scanf(" %d", &a[i]);
for (int i=0; i<n-1; i++) {
pq.push(a[i+1] - a[i] - 1);
}
ans = a[n-1] - a[0] + 1;
while (--k) ans -= pq.top(), pq.pop();
printf("%d", ans);
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... |