-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path177-the-meeting-place-cannot-be-changed.cpp
More file actions
66 lines (62 loc) · 1.61 KB
/
Copy path177-the-meeting-place-cannot-be-changed.cpp
File metadata and controls
66 lines (62 loc) · 1.61 KB
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
/*
* The Meeting Place Cannot Be Changed [780B]
* Problem: https://codeforces.com/problemset/problem/780/B
* Verdict: ACCEPTED Solved: 2022-02-05
* Language: C++20 (GCC 11-64)
* Runtime: 62 ms Memory: 1000 KB
* Tags: binary search
* Author: BidoTeima
* Source: https://codeforces.com/contest/780/submission/145230400
*/
/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS()
{
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
#define tc \
int tttttt,subtask; \
cin >> tttttt /*>> subtask*/; \
while (tttttt--)
#define sumrange(l, r, arr) (l == 0 ? arr[r] : arr[r] - arr[l - 1])
#define all(v) v.begin(), v.end()
ll x[60005],v[60005];
bool check(double ans, int n){
pair<double,double>intersection={-1e9,1e9};
for(int i = 0; i < n; i++){
double f = 1.0*x[i]-1.0*ans*1.0*v[i];
double s = 1.0*x[i]+1.0*ans*1.0*v[i];
intersection.first=max(intersection.first,f);
intersection.second=min(intersection.second,s);
if(intersection.first>intersection.second)
return 0;
}
return 1;
}
int main()
{
ACPLS();
int n;
cin>>n;
for(int i = 0; i < n; i++)
cin>>x[i];
for(int i = 0; i < n; i++)
cin>>v[i];
double lo=0.f,hi=1e9f,ans=hi;
for(int it = 0; it < 500; it++){
double mid = 0.5*(lo+hi);
if(check(mid,n))
hi=mid,ans=mid;
else
lo=mid;
}
cout<<setprecision(6)<<fixed<<ans;
}