# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
623051 | 54skyxenon | Mobile (BOI12_mobile) | C++17 | 1094 ms | 48148 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.
// https://oj.uz/problem/view/BOI12_mobile
#include <bits/stdc++.h>
using namespace std;
#define EPS 0.0001
#define pdd pair<double, double>
#define mp make_pair
int n, l;
vector<int> X, Y;
vector<pdd> merge(vector<pdd>& intervals) {
sort(intervals.begin(), intervals.end());
vector<pdd> new_intervals;
for (auto [start, end] : intervals) {
if (new_intervals.empty() || new_intervals.rbegin()->second < start) {
new_intervals.push_back(mp(start, end));
}
else {
new_intervals.rbegin()->second = max(new_intervals.rbegin()->second, end);
}
}
return new_intervals;
}
bool ok(double radius) {
vector<pdd> intervals({mp(0, 0), mp(l, l)});
for (int i = 0; i < n; i++) {
double x1 = X[i], y1 = Y[i];
double term = (radius * radius) - (y1 * y1);
if (term >= 0) {
double term_sqrt = sqrt(term);
intervals.push_back(mp(x1 - term_sqrt, x1 + term_sqrt));
}
}
intervals = merge(intervals);
for (int i = 0; i < intervals.size() - 1; i++) {
double midpt = (intervals[i].second + intervals[i + 1].first) / 2;
if (0 <= midpt && midpt <= l) {
return true;
}
}
return false;
}
int main() {
cin >> n >> l;
X.resize(n);
Y.resize(n);
for (int i = 0; i < n; i++) {
cin >> X[i] >> Y[i];
}
double lo = 0.0;
double hi = l;
while (lo + EPS < hi) {
double mid = (lo + hi) / 2;
if (!ok(mid)) {
hi = mid;
}
else {
lo = mid;
}
}
cout << lo << endl;
}
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... |