# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464155 | dqk | Mobile (BOI12_mobile) | C++17 | 1103 ms | 110020 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>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
double L;
std::cin >> n >> L;
std::vector<std::vector<int>> p(n, std::vector<int>(2, 0));
for (int i = 0; i < n; ++i) {
std::cin >> p[i][0] >> p[i][1];
p[i][1] = abs(p[i][1]);
}
double d1 = sqrt(p[0][0] * p[0][0] + p[0][1] * p[0][1]);
double d2 = sqrt((p[0][0] - L) * (p[0][0] - L) + p[0][1] * p[0][1]);
double lo = 0, hi = std::max(d1, d2);
while(hi - lo > 1e-3) {
double mi = (lo + hi) / 2;
std::vector<std::vector<double>> u;
bool ltok = false;
bool rtok = false;
for (int i = 0; i < n; ++i) {
double h = p[i][1];
if (h > mi)
continue;
double lf = p[i][0] - sqrt(mi * mi - h * h);
double rt = p[i][0] + sqrt(mi * mi - h * h);
if (rt < 0.0 || lf > L)
continue;
lf = std::max(lf, 0.0);
rt = std::min(rt, L);
u.push_back({lf, rt});
if (rt == L)
rtok = true;
if (lf == 0.0)
ltok = true;
}
//sort(u.begin(), u.end());
bool ok = rtok & ltok;
for (int i = 0; i < u.size() - 1 && ok; ++i) {
if (u[i + 1][0] > u[i][1])
ok = false;
}
if (ok) {
hi = mi;
}
else {
lo = mi;
}
}
std::cout << lo << "\n";
return 0;
}
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... |
# | 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... |
# | 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... |