#include<bits/stdc++.h>
#define int long long
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_multiset tree<long long, null_type,less_equal<long long>, rb_tree_tag,tree_order_statistics_node_update>
//#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
//st.order_of_key
//st.find_by_order
main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// freopen("deleg.in", "r", stdin);
// freopen("deleg.out", "w", stdout);
#endif
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
vector<int> x(n+1),h(n+1);
for(int i=1;i<=n;++i){
cin>>x[i]>>h[i];
}
vector<long double> ans(n+1);
long double eps=1e-5;
for(int i=1;i<=n;++i){
if(i==1){
ans[i]=h[i];
}else{
long double l=0,r=h[i]+eps;
while(l<r-eps){
long double mid=(l+r)/2;
bool ok=0;
for(int j=1;j<i;++j){
if(4*ans[j]*mid-x[i]*x[i]+2*x[i]*x[j]-x[j]*x[j]>eps){
ok=1;
break;
}
}
if(ok){
r=mid;
}else{
l=mid;
}
}
ans[i]=l;
}
cout<<fixed<<setprecision(4)<<ans[i]<<"\n";
}
}
Compilation message (stderr)
bal.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
17 | main(){
| ^~~~
# | 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... |