# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037334 | RaresFelix | Shortcut (IOI16_shortcut) | C++17 | 2025 ms | 600 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 vi = vector<int>;
using ll = long long;
using vll = vector<ll>;
using ii = pair<int, int>;
const ll INF = 1e18;
bool ok(int n, vi l, vi d, ll L, int c) {
vll sl(n, 0);
for (int i = 1; i < sl.size(); ++i)
sl[i] = sl[i - 1] + l[i - 1];
for(int a = 0; a < n; ++a)
for(int b = a; b < n; ++b) {
bool re = true;
for(int i = 0; i < n; ++i) {
for(int j = i + 1; j < n; ++j) {
if(sl[j] - sl[i] + d[i] + d[j] <= L) continue;
re &= (abs(sl[i] - sl[a]) + abs(sl[j] - sl[b]) + c + d[i] + d[j]) <= L;
}
}
if(re) return true;
}
return false;
}
ll find_shortcut(int n, vi l, vi d, int c) {
ll st = 0, dr = INF, mij;
while (st < dr) {
mij = (st + dr) / 2;
if (ok(n, l, d, mij, c)) dr = mij;
else st = mij + 1;
}
return st;
}
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... |