# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41099 | bugmenot111 | Stove (JOI18_stove) | C++14 | 30 ms | 1288 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 <cstdio>
#include <algorithm>
#define MAXN 100100
int diff[MAXN], a[MAXN];
int main(void) {
int n, k;
scanf("%d%d", &n, &k);
for(int i = 0; i < n; i++) scanf("%d", &a[i]);
int ans = a[n - 1] - a[0] + 1;
for(int i = 1; i < n; i++) diff[i] = a[i] - a[i - 1];
std::sort(diff + 1, diff + n, std::greater<int>());
for(int i = 1; i < k; i++) ans -= diff[i] - 1;
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... |