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>
using namespace std;
int n, k, d;
int data [100010];
int cnv_data[100010];
int get(bool f1,bool f2)
{
int divs = d-f1-f2;
int ret=0;
if(f1) ret+=cnv_data[0];
if(f2) ret+=cnv_data[k];
divs/=2;
int i;
for(i=k-1;i>=k-divs && i>=1;--i){
ret+=cnv_data[i];
}
return ret;
}
int main()
{
scanf("%d%d%d",&n,&k,&d);
int i;
for(i=0;i<k;++i) scanf("%d",data+i);
sort(data,data+k);
int ind=0;
cnv_data[0]=data[0]-1;
for(i=1;i<k;++i){
cnv_data[i]=data[i]-data[i-1]-1;
}
cnv_data[k]=n-data[k-1];
sort(cnv_data+1,cnv_data+k);
int ans=0;
for(i=0;i<4;++i) ans=max(ans,get(i>>1,i&1));
printf("%d\n",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... |