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;
#define endl '\n'
#define pll pair<long long, long long>
const int sz = 1e5 + 5;
pll a[sz];
long double f[sz];
long double dist(long long x, long long y, long long u, long long v){
x = x - u;
y = y - v;
return sqrt(x*x + y*y);
}
long double bs(long double x, long double y, long double p){
long double l = 0, r = 1e9;
for(int i=1;i<45;++i){
long double mid = (l + r) / 2;
if(dist(x, y, p, mid) >= mid + y){
l = mid;
}
else{
r = mid;
}
}
return (l + r) / 2;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("main.inp","r",stdin);
//freopen("main.out","w",stdout);
int n;
cin>>n;
for(int i=1;i<=n;++i){
cin >> a[i].first >> a[i].second;
f[i] = a[i].second;
for(int j=i-1;j>=1;--j){
f[i] = min(f[i], bs(a[j].first, f[j], a[i].first));
}
cout << fixed << setprecision(3) << f[i]<<endl;
}
return 0;
}
# | 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... |