# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302161 | peti1234 | Rail (IOI14_rail) | C++17 | 99 ms | 760 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 <bits/stdc++.h>
#include "rail.h"
using namespace std;
const int c=5002;
int a[c], b[c], pos=1, js, bs, el, id, x, kt;
vector<int> regi;
vector<pair<int, int> > bal, jobb;
int tav(int a, int b) {return getDistance(a, b);}
void findLocation(int n, int first, int l[], int s[]) {
for (int i=1; i<n; i++) {
a[i]=tav(0, i);
if (a[i]<a[pos]) pos=i;
}
l[0]=first, l[pos]=l[0]+a[pos], s[0]=1, s[pos]=2, kt=a[pos];
for (int i=1; i<n; i++) if (i!=pos) {
b[i]=tav(pos, i);
kt=min(kt, b[i]);
}
for (int i=1; i<n; i++) if (i!=pos) {
if (a[i]+2*kt==b[i]+a[pos]) jobb.push_back({a[i], i});
else bal.push_back({b[i], i});
}
sort(jobb.begin(), jobb.end()), sort(bal.begin(), bal.end());
js=jobb.size(), bs=bal.size();
if (js) {
id=jobb[0].second, el=id;
s[id]=2, l[id]=l[0]+a[id];
regi.push_back(id);
for (int i=1; i<js; i++) {
id=jobb[i].second, x=tav(el, id);
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... |