Submission #14062

#TimeUsernameProblemLanguageResultExecution timeMemory
14062kipa00정전 (OJUZ10_blackout)C++98
100 / 100
55 ms2384 KiB
#include <cstdio> #include <algorithm> using namespace std; int location[150000]; int L; int dist(int a, int b) { int t = 2 * L - (b - a); return t > 0 ? t : 0; } int main() { int N, i; long long int l = 0; scanf("%d%d", &N, &L); for (i=0; i<N; ++i) { scanf("%d", location+i); } stable_sort(location, location+N); for (i=1; i<N; ++i) { l += dist(location[i - 1], location[i]); } for (i=2; i<N; ++i) { l -= dist(location[i - 2], location[i]); } printf("%lld\n", l); 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...