# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99567 | lovemathboy | Stove (JOI18_stove) | C++14 | 43 ms | 2336 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;
int n, k;
vector<int> a;
priority_queue<int> pq;
int main() {
scanf("%d %d", &n, &k);
a.resize(n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
if (i > 0) {
pq.push(a[i] - a[i-1] - 1);
}
}
int ans = a[n-1] - a[0] + 1;
while (k > 1) {
k--;
ans -= pq.top();
pq.pop();
}
printf("%d\n", 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... |