# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59949 | gusfring | Stove (JOI18_stove) | C++14 | 41 ms | 10304 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>
const int MAXN = 1e5 + 5;
int t[MAXN], a[MAXN], N, K;
int main(){
int N, K;
scanf("%d %d", &N, &K);
for(int i=0; i<N; ++i) scanf("%d", &t[i]);
int res = t[N - 1] + 1 - t[0];
for(int i=0; i<N-1; ++i) a[i] = t[i + 1] - t[i] - 1;
std::sort(a, a + N - 1, std::greater<int>());
for(int i=0; i<K-1; ++i) res -= a[i];
printf("%d",res);
}
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... |