# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
542048 | lunchbox | Stove (JOI18_stove) | C++17 | 20 ms | 1696 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 main() {
int n, k, ans;
scanf("%d%d", &n, &k), k--;
vector<int> a(n);
for (int &x : a)
scanf("%d", &x);
ans = a[n - 1] - a[0] + 1;
for (int i = 0; i + 1 < n; i++)
a[i] = a[i + 1] - a[i] - 1;
a.pop_back();
sort(a.rbegin(), a.rend());
for (int i = 0; i < k; i++)
ans -= a[i];
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... |