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<stdio.h>
#include<algorithm>
using namespace std;
int C1, C2, C[101000], w[101000];
int L, n, K, Res;
void Do(int S, int m){
if (m < 0)return;
int i;
for (i = n - 1; i >= 1; i--){
m -= 2;
if (m < 0)break;
S += C[i];
}
if (Res < S)Res = S;
}
int main()
{
int i;
scanf("%d%d%d", &L, &n, &K);
for (i = 1; i <= n; i++){
scanf("%d", &w[i]);
}
C1 = w[1] - 1;
C2 = L - w[n];
for (i = 1; i < n; i++){
C[i] = w[i + 1] - w[i] - 1;
}
sort(C + 1, C + n);
if (C1 > C2)swap(C1, C2);
Do(0,K);
Do(C2, K - 1);
Do(C1 + C2, K - 2);
printf("%d\n", Res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |