-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Get_together.cpp
67 lines (67 loc) · 1.55 KB
/
A_Get_together.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
using namespace std;
#define debug(x...) { cout << "(" << #x << ")" << " = ( "; PRINT(x); }
template <typename T1> void PRINT(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void PRINT(T1 t1, T2... t2) { cout << t1 << " , "; PRINT(t2...); }
#define all(v) (v).begin(), (v).end()
void solve();
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.setf(ios::fixed);
cout.precision(10);
srand(time(NULL));
solve();
}
void solve()
{
int n;
cin>>n;
vector<pair<long double,long double>>v;
for(int i=0;i<n;i++)
{
long double x,y;
cin>>x>>y;
v.push_back({x,y});
}
long double error=0.00000001;
long double low=0;
long double high=1e18;
long double res=1e10;
function<int(long double)>f=[&](long double mid)->int{
// vector<pair<long double,long double>>vv;
long double l=-1e18;
long double r=1e18;
for(int i=0;i<n;i++)
{
long double x=v[i].first-(mid*v[i].second);
long double y=v[i].first+(mid*v[i].second);
l=max(l,x);
r=min(r,y);
// vv.push_back({x,y});
}
if(l>r)
return 0;
return 1;
};
int count=0;
while(high-low>=error)
{
long double mid=(low+high)/(2*1.0);
if(f(mid))
{
res=mid;
high=mid-error;
}
else
{
low=mid+error;
}
if(count>100)
break;
count++;
}
cout<<res<<endl;
}