# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
967655 | vjudge1 | Stove (JOI18_stove) | C++17 | 0 ms | 348 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;
long long ans = 1ll;
int main()
{
priority_queue<long long> pq;
int n, k;
long long pre, curr; scanf("%d %d %lld", &n, &k, &pre);
if (n == k) return printf("0"), 0;
for (int i = 1;i < n;i++){
scanf("%lld", &curr);
pq.push(curr-pre+1);
ans += curr-pre+1;
pre = curr;
}
while (--k){
ans -= pq.top();
pq.pop();
}
printf("%lld", ans);
}
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... |