提交时间:2023-12-07 18:41:19
运行 ID: 23991
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define lc(x) ((x) << 1) #define rc(x) ((x) << 1 | 1) //#define double long double #define pii pair<double, double> #define p1(x) ((x).first) #define p2(x) ((x).second) int n, m; int t[200300], x[200300]; double b[200030]; pii Hunter[200030]; pii Prey[200030]; set<double> S; inline bool cmp(pii A, pii B) { return A > B; } bool u = 0; inline bool chk(double v) { for(int i=1;i<=n;i++) if(fabs(x[i])>t[i]*v)return 0; S.clear(); for (int i = 1; i <= n; i++) Hunter[i]={ t[i] * v + x[i], t[i] * v - x[i] }, Prey[i]={ t[i] * v + x[i], t[i] * v - x[i] }; for (int i = 1; i <= m + 1; i++) Hunter[n+i]={ 0, 0 }; sort(Prey+1, Prey+n+1, cmp); sort(Hunter+1, Hunter+n+m+2, cmp); int it = 1; int cnt = 0; for (int i=1;i<=n+m+1;i++) { while (it != n+1 && p1(Prey[it]) >= p1(Hunter[i]) && Prey[it]!= Hunter[i]) S.insert(p2(Prey[it])), it++; auto it = S.lower_bound(p2(Hunter[i])); if (it != S.end()) { S.erase(it); cnt++; } } return cnt == n; } signed main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); // freopen("s4.in","r",stdin); //freopen("avatar.in", "r", stdin); //freopen("avatar.out", "w", stdout); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> t[i] >> x[i]; // chk(0); // return 0; double l = 0, r = 2e6; while (r - l > 1e-9) { double mid = (l + r) / 2; if (chk(mid)) r = mid; else l = mid + 1e-9; } // u=1; // chk(r); printf("%.4lf\n", l); cout.flush(); return 0; }