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 N, K, D, P, A[100002], Cnt, Ans;
int main(void) {
int i, Prev=0, t1, t2;
scanf("%d %d %d",&N,&K,&D);
for(i=1 ; i<=K ; i++) {
scanf("%d",&P);
A[++Cnt]=P-Prev-1;
Prev=P;
}
A[++Cnt]=N-Prev;
sort(A+2,A+Cnt);
t1=t2=0;
for(i=Cnt-1 ; i>=2 ; i--) {
t2+=2;
if(t2>D)
break;
t1+=A[i];
}
if(Ans<t1)
Ans=t1;
t1=A[1];
t2=1;
for(i=Cnt-1 ; i>=2 ; i--) {
t2+=2;
if(t2>D)
break;
t1+=A[i];
}
if(Ans<t1)
Ans=t1;
t1=A[Cnt];
t2=1;
for(i=Cnt-1 ; i>=2 ; i--) {
t2+=2;
if(t2>D)
break;
t1+=A[i];
}
if(Ans<t1)
Ans=t1;
t1=A[1]+A[Cnt];
t2=2;
for(i=Cnt-1 ; i>=2 ; i--) {
t2+=2;
if(t2>D)
break;
t1+=A[i];
}
if(Ans<t1)
Ans=t1;
printf("%d",Ans);
return 0;
}
# | 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... |