이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
long long find_shortcut(int n, vector<int> l, vector<int> d, int c) {
vector<long long> x(n);
for (int i = 1; i < n; i++) {
x[i] = x[i - 1] + l[i - 1];
}
auto Check = [&](long long diam) {
vector<array<long long, 4>> sq;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (d[i] + d[j] + x[j] - x[i] <= diam) {
continue;
}
long long r = diam - d[i] - d[j] - c;
if (r < 0) {
return false;
}
sq.push_back({x[i] + x[j] - r, x[j] - r - x[i], x[i] + x[j] + r, x[j] + r - x[i]});
}
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
long long cx = x[i] + x[j];
long long cy = x[j] - x[i];
bool ok = true;
for (auto& p : sq) {
if (p[0] <= cx && cx <= p[2] && p[1] <= cy && cy <= p[3]) {
//...
} else {
ok = false;
break;
}
}
if (ok) {
return true;
}
}
}
return false;
};
long long low = 0, high = 1e18, ans = 0;
while (low <= high) {
long long mid = (low + high) >> 1;
if (Check(mid)) {
ans = mid;
high = mid - 1;
} else {
low = mid + 1;
}
}
return ans;
}
| # | 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... |