# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
915214 | vjudge1 | Shortcut (IOI16_shortcut) | C++17 | 2065 ms | 688 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;
long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c) {
vector<int64_t> a(n), b(n); // a = x + d, b = x - d
vector<int64_t> x(n);
for (int i = 1; i < n; i++) x[i] = x[i - 1] + l[i - 1];
for (int i = 0; i < n; i++) a[i] = x[i] + d[i], b[i] = x[i] - d[i];
auto check = [&](int64_t target) {
for (int p = 0; p < n; p++) {
for (int q = p + 1; q < n; q++) {
bool ok = 1;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (x[j] - x[i] + d[i] + d[j] > target) {
if (abs(x[i] - x[p]) + abs(x[j] - x[q]) + d[i] + d[j] + c > target) ok = 0;
}
}
}
if (ok == 1) return 1;
}
}
return 0;
};
int64_t low = 0, high = 1ll << 60;
while (low < high) {
int64_t mid = low + high >> 1;
if (check(mid)) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
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... |
# | 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... |