# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
762029 | HamletPetrosyan | Rail (IOI14_rail) | C++17 | 43 ms | 492 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "rail.h"
using namespace std;
#define ll long long
ll n;
ll z, h;
ll d0[5005];
ll dh[5005];
void findLocation(int N, int l0, int location[], int stype[])
{
n = N;
z = l0;
stype[0] = 1;
location[0] = z;
if(n == 1) return;
for(int i = 1; i < n; i++){
d0[i] = getDistance(0, i);
}
h = 1;
ll mn = d0[1];
for(int i = 2; i < n; i++){
if(mn > d0[i]){
h = i;
mn = d0[i];
}
}
location[h] = z + mn;
stype[h] = 2;
dh[h] = 0;
ll st = dh[0] = d0[h];
for(int i = 1; i < n; i++){
if(i == h) continue;
dh[i] = getDistance(h, i);
}
for(int i = 1; i < n; i++){
if(i == h) continue;
if(d0[i] <= dh[i]){
location[i] = z + d0[i];
stype[i] = 2;
}
else {
location[i] = location[h] - dh[i];
stype[i] = 1;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |