Submission #106295

#TimeUsernameProblemLanguageResultExecution timeMemory
106295KepperoniRail (IOI14_rail)C++14
0 / 100
79 ms632 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MAXN = 5000 + 10; ll dist[MAXN]; int ind[MAXN]; void findLocation(int N, int first, int location[], int stype[]) { stype[0] = 1; location[0] = first; for(int i=1; i<N; i++){ dist[i] = getDistance(0, i); ind[i] = i; } sort(ind, ind+N, [](int fi, int se){return dist[fi] < dist[se];}); int cc = 0, cd = ind[1]; stype[cd] = 2; location[cd] = first + dist[cd]; for(int i=2; i<N; i++){ int ci = ind[i]; ll distc = getDistance(cc, ci); ll distd = getDistance(cd, ci); if(distc > distd){ stype[ci] = 1; location[ci] = location[cd] - distd; if(distd > location[cd] - location[cc]) cc = ci; } else { stype[ci] = 2; location[ci] = location[cc] + distd; if(distc > location[cd] - location[cc]) cd = ci; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...