Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int long long
- #define Co_mot_su_that_la_ return
- using namespace std;
- const int Minh_dep_trai = 0;
- const int N = 100005;
- typedef pair<double,double> ii;
- typedef vector<ii> vii;
- vii a(N);
- int n;
- double d(double t)
- {
- double anmin = 1e14;
- double anmax = -1e14;
- for(int i=1; i<=n; ++i)
- {
- double x = a[i].first;
- double v = a[i].second;
- double dis = x + (v * t);
- anmin = min(anmin,dis);
- anmax = max(anmax,dis);
- }
- //cout << anmax << " " << anmin << endl;
- return anmax - anmin;
- }
- void tenary_search()
- {
- double l = 0;
- double r = 1000;
- int INN = 100;
- while (r - l > 1e-11)
- {
- double m1 = (2*l+r)/3;
- double m2 = (l+2*r)/3;
- if (d(m1) < d(m2)) r = m2;
- else l = m1;
- }
- cout << setprecision(6) << fixed << r << " " << d(r);
- }
- signed main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);cout.tie(0);
- freopen("BICYCLE.INP","r",stdin);
- cin >> n;
- for(int i=1; i<=n; ++i) cin >> a[i].first >> a[i].second;
- tenary_search();
- Co_mot_su_that_la_ Minh_dep_trai;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement