# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204689 | my99n | Stove (JOI18_stove) | C++14 | 38 ms | 2292 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 t[100100];
priority_queue<int> heap;
long long sum;
int main(){
int n, k;
scanf("%d %d", &n, &k); k--;
for (int i = 0; i < n; i++) scanf("%d", &t[i]);
for (int i = 1; i < n; i++) heap.push(t[i]-t[i-1]-1);
sum = t[n-1] - t[0] + 1;
while (k--) sum -= heap.top(), heap.pop();
printf("%lld", sum);
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... |