Submission #12304

#TimeUsernameProblemLanguageResultExecution timeMemory
12304baneling100격자 보존하기 (GA9_preserve)C++98
100 / 100
28 ms1476 KiB
#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 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...