Submission #13973

#TimeUsernameProblemLanguageResultExecution timeMemory
13973kriii정전 (OJUZ10_blackout)C++14
100 / 100
51 ms1668 KiB
#include <stdio.h> #include <algorithm> using namespace std; int N,L,X[150005]; int main() { scanf ("%d %d",&N,&L); for (int i=0;i<N;i++) scanf ("%d",&X[i]); sort(X,X+N); int al = 0x80000000, bl = 0x80000000; long long ans = 0; for (int i=0;i<N;i++){ if (i % 2){ int s = X[i] - L; if (al >= s) s = al; if (s <= bl) ans += bl - s; al = X[i] + L; } else{ int s = X[i] - L; if (bl >= s) s = bl; if (s <= al) ans += al - s; bl = X[i] + L; } } printf ("%lld\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...