# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
735127 | ace_in_the_hole | Mobile (BOI12_mobile) | C++17 | 292 ms | 12044 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;
typedef long long Int;
typedef double Real;
const Real EPS = 1e-6;
bool leq(Real x, Real y) { return x-EPS <= y; }
const int N = 1e6 + 50;
int n,L, x[N];
Int y[N];
bool check(Real dis) {
Real rightmost = 0;
Real d_squared = dis * dis;
for (int i = 1; i <= n; i++) {
if (leq(dis, y[i])) continue;
Real lef = x[i] - sqrt(d_squared - y[i]);
Real rig = 2*x[i] - lef;
if (leq(lef, rightmost)) {
rightmost = max(rightmost, rig);
if (leq(L,rightmost)) return true;
}
}
return false;
}
void solve()
{
cin >> n >> L;
for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
//preprocessing
Real max_dist = L;
for (int i = 1; i <= n; i++) {
y[i] *= y[i];
int x_dis = max(abs(x[i]), abs(L - x[i]));
Real cur_dist = sqrt(y[i] + 1ll * x_dis * x_dis);
max_dist = max(max_dist, cur_dist);
}
const Real DEL = 5e-4;
Real ans = 0;
for (Real low = 0, high = max_dist + 100; high - low >= DEL; ) {
Real mid = (low + high) / 2;
if (check(mid)) high = mid;
else ans = low = mid;
}
cout << fixed << setprecision(15) << ans;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define task "WF"
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
solve();
}
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... |