# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
633259 | afatpotato | Mobile (BOI12_mobile) | C++14 | 1096 ms | 56804 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>
using namespace std;
bool solve(double x);
vector<pair<double, double> > tower;
long long n, l;
int main() {
cin >> n >> l;
tower.resize(n);
for (int i = 0; i < n; i++) {
cin >> tower[i].first >> tower[i].second;
}
double low = 0;
double high = 4e9;
double ans = 0;
while (high - low > 1e-4) {
double mid = (low + high) / 2;
if (solve(mid)) {
ans = mid;
high = mid;
} else {
low = mid;
}
}
cout << fixed;
cout << setprecision(9);
cout << ans << endl;
}
bool solve(double x) {
vector<pair<double, double> > v;
for (int i = 0; i < n; i++) {
if (tower[i].second > x) {
continue;
}
double d = sqrt(x * x - tower[i].second * tower[i].second);
if (tower[i].first + d < 0) {
continue;
}
v.push_back(make_pair(max(tower[i].first - d, (double) 0), max(tower[i].first + d, (double) 0)));
}
sort(v.begin(), v.end());
if (v[0].first > 0) {
return false;
}
double r = v[0].second;
for (int i = 1; i < v.size(); i++) {
if (r < v[i].first) {
return false;
} else {
r = max(r, v[i].second);
}
}
if (r < l) {
return false;
}
return true;
}
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... |