# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126350 | EntityIT | Stove (JOI18_stove) | C++14 | 28 ms | 2088 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;
const int N = (int)1e5 + 5;
int n, K, a[N], dist[N], ans;
int main () {
scanf("%d %d", &n, &K);
for (int i = 0; i < n; ++i) scanf("%d", a + i);
for (int i = 1; i < n; ++i) dist[i] = a[i] - a[i - 1] - 1;
sort(dist + 1, dist + n);
ans = n;
for (int i = 1; i <= n - K; ++i) ans += dist[i];
printf("%d", 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... |