# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1022513 | RaresFelix | Roller Coaster Railroad (IOI16_railroad) | C++17 | 0 ms | 0 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 "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const ll INF = 1e18;
ll find_shortcut(int n, vi l, vi d, int c) {
vll s(n, 0), alpha(n, 0), beta(n, 0);
for(int i = 1; i < n; ++i) {
s[i] = s[i - 1] + l[i - 1];
}
ll re = INF;
auto dist = [&](int i, int j, int a, int b) {
if(i > j) swap(i, j);
return d[i] + d[j] + min(abs(s[i] - s[j]), abs(s[i] - s[a]) + c + abs(s[j] - s[b]));
};
for(int a = 0; a < n; ++a)
for(int b = a; b < n; ++b) {
ll cre = 0;
for(int i = 0; i < n; ++i)
for(int j = i; j < n; ++j) cre = max(cre, dist(i, j, a, b));
re = min(re, cre);
}
return re;
}