Submission #12816

#TimeUsernameProblemLanguageResultExecution timeMemory
12816Namnamseo격자 보존하기 (GA9_preserve)C++98
0 / 100
28 ms1868 KiB
#include <cstdio> #include <algorithm> using namespace std; int n, k, d; int data[100010]; int cnv_data[100010]; 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; if(d&1){ for(i=k-1;i>=(k-d/2) && i>=1;--i){ ans+=cnv_data[i]; } ans+=max(cnv_data[0],cnv_data[k]); } else { for(i=k-1;i>(k-d/2) && i>=1;--i){ ans+=cnv_data[i]; } ans+=max(cnv_data[0],max(cnv_data[k],cnv_data[k-d/2])); } printf("%d\n",ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...