Submission #14716

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