Submission #14717

#TimeUsernameProblemLanguageResultExecution timeMemory
14717baneling100정전 (OJUZ10_blackout)C++98
100 / 100
51 ms2256 KiB
#include <stdio.h> #include <algorithm> #define N_MAX 150000 using namespace std; long long N, L, Light[N_MAX+1], Res; int main(void) { int i; scanf("%lld %lld",&N,&L); for(i=1 ; i<=N ; i++) scanf("%lld",&Light[i]); sort(Light+1,Light+N+1); if(N==1) { printf("0"); return 0; } if(Light[1]-Light[2]+2*L>0) Res=Light[1]-Light[2]+2*L; for(i=3 ; i<=N ; i++) { if(Light[i-2]+L<Light[i]-L) { if(Light[i-1]-Light[i]+2*L>0) Res+=Light[i-1]-Light[i]+2*L; } else Res+=Light[i-1]-Light[i-2]; } printf("%lld",Res); 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...