Problem:
Problem Statement
Your friend, Tatsumi, is a producer of Immortal Culture Production in Chiba (ICPC). His company is planning to form a zombie rock band named Gray Faces and cheer Chiba Prefecture up.
But, unfortunately, there is only one zombie in ICPC. So, Tatsumi decided to release the zombie on a platform of Soga station to produce a sufficient number of zombies. As you may know, a zombie changes a human into a new zombie by passing by the human. In other words, a human becomes a zombie when the human and a zombie are at the same point. Note that a zombie who used to be a human changes a human into a zombie too.
The platform of Soga station is represented by an infinitely long line, and Tatsumi will release a zombie at a point with coordinate $x_Z$. After the release, the zombie will start walking in the positive direction at $v_Z$ per second. If $v_Z$ is negative, the zombie will walk in the negative direction at $|v_Z|$ per second.
There are $N$ humans on the platform. When Tatsumi releases the zombie, the $i$-th human will be at a point with coordinate $x_i$ and will start walking in the positive direction at $v_i$ per second. If $v_i$ is negative, the human will walk in the negative direction at $|v_i|$ per second as well as the zombie.
For each human on the platform, Tatsumi wants to know when the human becomes a zombie. Please help him by writing a program that calculates a time when each human on the platform becomes a zombie.
Input
The input consists of a single test case in the following format.
$N$
$x_Z$ $v_Z$
$x_1$ $v_1$
$\vdots$
$x_N$ $v_N$
The first line consists of an integer $N \, (1 \le N \le 2 \times 10^5)$ which is the number of humans on a platform of Soga station. The second line consists of two integers $x_Z \, (-10^9 \le x_Z \le 10^9)$ and $v_Z \, (-10^9 \le v_Z \le 10^9)$ separated by a space, where $x_Z$ is an initial position of a zombie Tatsumi will release and $v_Z$ is the velocity of the zombie. The $i$-th line in the following $N$ lines contains two integers $x_i \, (-10^9 \le x_i \le 10^9)$ and $v_i \, (-10^9 \le v_i \le 10^9)$ separated by a space, where the $x_i$ is an initial position of the $i$-th human and $v_i$ is the velocity of the human. There is no human that shares their initial position with the zombie. In addition, initial positions of the humans are different from each other.
Output
The output consists of $N$ lines. In the $i$-th line, print how many seconds it will take for the $i$-th human to become a zombie. If the $i$-th human will never become a zombie, print $-1$ instead. The answer will be considered as correct if the values output have an absolute or relative error less than $10^{-9}$.
Examples
Input
Output
6
3 1
-5 0
5 0
-4 -3
0 -2
6 -3
2 -1
3.66666666666667
2.00000000000000
-1
6.00000000000000
0.75000000000000
2.00000000000000
5
31415 -926
5358 979
323846 26
-433832 7950
288 -4
-1971 -69
13.67821522309711
95.61812216052499
52.41629112212708
33.76030368763558
38.95682613768962

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1ll << 60;
#define REP(i, n) for(ll i=0; i <ll(n); i++)
template <class T> using V = vector<T>;
template <class A, class B>
bool chmax(A &a, B b) { return a < b && (a=b, true); }
template <class A, class B>
bool chmin(A &a, B b) { return b < a && (a=b, true); }

// a / b
struct Frac {
  using Z = ll;
  Z a, b;
  Frac(Z x = 0, Z y = 1) : a(x), b(y) {
    if(b<0) a = -a, b = -b;
  }
  Z z() const { return a / b - ((a ^ b) < 0 && a % b); }
  friend auto operator<=>(Frac l, Frac r){
    Z lz = l.z(), rz = r.z();
    if(lz != rz) return lz <=> rz;
    return (l.a - lz * l.b) * r.b <=> (r.a - rz * r.b) * l.b;
  }
  Frac operator-() const { return {-a, b}; }
};
const Frac InfFrac = { 1ll << 61, 1 };
struct Line {
  ll a, b;
  Frac crossX(Line r) const {
    if(a == r.a) return b < r.b ? -InfFrac : InfFrac;
    return Frac(r.b - b, a - r.a);
  }
  friend auto operator<=>(Line l, Line r){
    return l.a != r.a ? l.a <=> r.a : l.b <=> r.b;
  }
};

void testcase(){
  ll N; cin >> N;
  ll offX, offZ; cin >> offX >> offZ;
  V<ll> X(N), Z(N);
  REP(i,N) cin >> X[i] >> Z[i];
  REP(i,N) X[i] -= offX, Z[i] -= offZ;

  V<double> ans(N, 1.0e100);
  REP(t,2){
    V<Line> lines;
    lines.push_back({ 0, 0 });
    REP(i,N) if(X[i] < 0 && Z[i] > 0) lines.push_back({ Z[i], X[i] });
    sort(lines.begin(), lines.end());

    V<Line> exts;
    for(auto a : lines){
      while(exts.size() >= 2){
        auto b = exts[exts.size() - 1];
        auto c = exts[exts.size() - 2];
        if(b < a && c.crossX(b) < b.crossX(a)) break;
        exts.pop_back();
      }
      exts.push_back(a);
    }
    V<Frac> pts;
    pts.push_back({0,1});
    for(int i=0; i+1<exts.size(); i++){
      pts.push_back(exts[i].crossX(exts[i+1]));
    }
    pts.push_back(InfFrac);

    //cout << "##" << endl;
    //for(auto [u,v] : exts) cout << "(" << u << "," << v << ")";
    //cout << endl;
    //for(auto  [u,v] : pts) cout << "(" << u << "," << v << ")";
    //cout << endl;

    REP(i,N){
      Line ln = { Z[i], X[i] };
      if(X[i] >= 0){
        if(exts.back().a <= Z[i]) continue;
        ll l = -1, r = exts.size();
        while(1){
          if(l + 1 == r){
            chmin(ans[i], double(pts[r].a) / double(pts[r].b));
            break;
          }
          ll m = (l + r + 2) / 2 - 1;
          if(exts[m] <= ln){ l = m; continue; }
          auto cr = exts[m].crossX(ln);
          if(cr <= pts[m]){ r = m; continue; }
          if(pts[m+1] <= cr){ l = m; continue; }
          chmin(ans[i], double(cr.a) / double(cr.b));
          break;
        }
      }
    }
    
    for(auto& a : X) a *= -1;
    for(auto& a : Z) a *= -1;
  }

  cout.precision(20);
  for(auto a : ans){
    if(a > 1.0e16){ cout << "-1\n"; continue; }
    cout << a << "\n";
  }
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  testcase();
  return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 14764
final_rank: 3

code_snippet: #include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=500005;
struct ab
{
	int x,y,id;
	ab operator- (const ab a){return (ab){x-a.x,y-a.y};}
	int operator^ (const ab a){return x*a.y-y*a.x;}
} t1[N],t2[N],s[N],q[N];
int x[N],v[N],top,Q,flag[N];
double ans[N];
int cmp(ab x,ab y)
{
	if(x.x==y.x) return x.y<y.y;
	return x.x<y.x;
}
int cmp1(ab x,ab y)
{
	return x.y*y.x-x.x*y.y<0;
}
int le(ab x,ab y,ab z)
{
	return ((z-x)^(y-x))<=0;
}
double get(ab x,ab y)
{
	return ((double)x.y-y.y)/(x.x-y.x);
}
signed main()
{
	int n,X,T,tot1=0,tot2=0;
	scanf("%lld%lld%lld",&n,&X,&T);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",x+i,v+i);
		x[i]-=X,v[i]-=T;
		if(x[i]<=0&&v[i]>0) t1[++tot1]=(ab){-x[i],v[i],0};
		if(x[i]>=0&&v[i]<0) t2[++tot2]=(ab){x[i],-v[i],0};
	}
	t1[++tot1]=(ab){0,0,0};
	t2[++tot2]=(ab){0,0,0};
	sort(t2+1,t2+1+tot2,cmp);
	for(int i=1;i<=tot2;i++)
	{
		while(top>1&&le(s[top-1],s[top],t2[i])) top--;
		s[++top]=t2[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(x[i]>0) continue;
		q[++Q]=(ab){x[i],-v[i],i};
	}
	for(int i=1;i<=Q;i++)
	{
		int l=1,r=top,now=1;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(le(s[mid-1],s[mid],q[i])||mid==1) l=mid+1,now=mid;
			else r=mid-1;
		}
		if(s[now].x==q[i].x) ans[q[i].id]=0;
		else if(s[now].y==q[i].y||s[now].y<q[i].y||s[now].x<q[i].x) flag[q[i].id]=-1;
		else ans[q[i].id]=((double)s[now].x-q[i].x)/(s[now].y-q[i].y);
	}
	sort(t1+1,t1+1+tot1,cmp);
	top=0;
	for(int i=1;i<=tot1;i++)
	{
		while(top>1&&le(s[top-1],s[top],t1[i])) top--;
		s[++top]=t1[i];
	}
	Q=0;
	for(int i=1;i<=n;i++)
	{
		if(x[i]<0) continue;
		q[++Q]=(ab){-x[i],v[i],i};
	}
	sort(q+1,q+1+Q,cmp1);
	for(int i=1;i<=Q;i++)
	{
		int l=1,r=top,now=1;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(le(s[mid-1],s[mid],q[i])||mid==1) l=mid+1,now=mid;
			else r=mid-1;
		}
		if(s[now].x==q[i].x) ans[q[i].id]=0;
		else if(s[now].y==q[i].y||s[now].y<q[i].y||s[now].x<q[i].x) flag[q[i].id]=-1;
		else ans[q[i].id]=((double)s[now].x-q[i].x)/(s[now].y-q[i].y);
	}
	for(int i=1;i<=n;i++)
	{
		if(flag[i]) printf("-1\n");
		else printf("%.14lf\n",ans[i]);
	}
	return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 33800
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, x) for(int i = 0; i < (x); i++)
#define all(v) v.begin(), v.end()

constexpr double INF = 1e12;
struct Line {
	mutable double k, m, p;
	bool operator<(const Line& o) const { return k < o.k; }
	bool operator<(double x) const { return p < x; }
};

struct LineContainer : multiset<Line, less<>> {
	const double inf = 1. / 0.;
	double div(double a, double b) { return a / b; }
	bool isect(iterator x, iterator y) {
		if(y == end()) return x->p = inf, 0;
		if(x->k == y->k)
			return x->p = x->m > y->m ? inf : -inf;
		else
			x->p = (y->m - x->m) / (x->k - y->k);
		return x->p >= y->p;
	}
	void add(double k, double m) {
		auto z = insert({k, m, 0}), y = z++, x = y;
		while(isect(y, z)) z = erase(z);
		if(x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while((y = x) != begin() && (--x)->p >= y->p) isect(x, erase(y));
	}

	double query(double x) {
		assert(!empty());
		auto l = *lower_bound(x);
		return l.k * x + l.m;
	}
};

using ll = long long;

vector<double> sol(vector<pair<ll, ll>> zombies, vector<tuple<ll, ll, int>> persons, int n) {
	LineContainer lc;
	lc.add(0, 0);

	for(auto [x, v] : zombies) {
		lc.add(v, x);
	}

	vector<double> ret(n, INF);

	for(auto [x, v, idx] : persons) {
		double left = 0;
		double right = INF;
		rep(_, 150) {
			double mid = (left + right) / 2;
			double cht = lc.query(mid);
			double run = v * mid + x;
			if(run < cht) {
				right = mid;
			} else {
				left = mid;
			}
		}

		ret[idx] = left;
	}

	return ret;
}

int main() {
	int n;
	cin >> n;
	ll zx, zv;
	cin >> zx >> zv;
	vector<tuple<ll, ll, int>> xvi;
	rep(id, n) {
		ll x, v;
		cin >> x >> v;
		xvi.emplace_back(x - zx, v - zv, id);
	}

	sort(all(xvi));

	int mid = n;
	rep(i, n) {
		if(get<0>(xvi[mid]) > 0) {
			mid = i;
			break;
		}
	}

	vector<pair<ll, ll>> zxv;
	vector<tuple<ll, ll, int>> pxvi;

	auto solve = [&]() -> vector<double> {
		rep(i, n) {
			ll x, v;
			int idx;
			tie(x, v, idx) = xvi[i];
			if(x < 0 && v > 0) zxv.emplace_back(x, v);
			if(x > 0) pxvi.emplace_back(x, v, idx);
		}
		auto res = sol(zxv, pxvi, n);
		zxv.clear();
		pxvi.clear();

		return res;
	};

	auto r = solve();
	for(auto& [x, v, idx] : xvi) {
		x *= -1;
		v *= -1;
	}
	auto s = solve();
	cout << fixed << setprecision(20);
	rep(i, n) {
		r[i] = min(r[i], s[i]);
		if(r[i] > INF * 2 / 3) {
			cout << "-1\n";
		} else {
			cout << r[i] << '\n';
		}
	}
}
accuracy: 0.6774193548387096
time_ms: 1950
memory_kb: 27204
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, x) for(int i = 0; i < (x); i++)
#define all(v) v.begin(), v.end()

constexpr double INF = 1e12;
struct Line {
	mutable double k, m, p;
	bool operator<(const Line& o) const { return k < o.k; }
	bool operator<(double x) const { return p < x; }
};

struct LineContainer : multiset<Line, less<>> {
	const double inf = 1. / 0.;
	double div(double a, double b) { return a / b; }
	bool isect(iterator x, iterator y) {
		if(y == end()) return x->p = inf, 0;
		if(x->k == y->k)
			return x->p = x->m > y->m ? inf : -inf;
		else
			x->p = (y->m - x->m) / (x->k - y->k);
		return x->p >= y->p;
	}
	void add(double k, double m) {
		auto z = insert({k, m, 0}), y = z++, x = y;
		while(isect(y, z)) z = erase(z);
		if(x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while((y = x) != begin() && (--x)->p >= y->p) isect(x, erase(y));
	}

	double query(double x) {
		assert(!empty());
		auto l = *lower_bound(x);
		return l.k * x + l.m;
	}
};

using ll = long long;

vector<double> sol(vector<pair<ll, ll>> zombies, vector<tuple<ll, ll, int>> persons, int n) {
	LineContainer lc;
	lc.add(0, 0);

	for(auto [x, v] : zombies) {
		lc.add(v, x);
	}

	vector<double> ret(n, INF);

	for(auto [x, v, idx] : persons) {
		double left = 0;
		double right = INF;
		rep(_, 100) {
			double mid = (left + right) / 2;
			double cht = lc.query(mid);
			double run = v * mid + x;
			if(run < cht) {
				right = mid;
			} else {
				left = mid;
			}
		}

		ret[idx] = left;
	}

	return ret;
}

int main() {
	int n;
	cin >> n;
	ll zx, zv;
	cin >> zx >> zv;
	vector<tuple<ll, ll, int>> xvi;
	rep(id, n) {
		ll x, v;
		cin >> x >> v;
		xvi.emplace_back(x - zx, v - zv, id);
	}

	sort(all(xvi));

	int mid = n;
	rep(i, n) {
		if(get<0>(xvi[mid]) > 0) {
			mid = i;
			break;
		}
	}

	vector<pair<ll, ll>> zxv;
	vector<tuple<ll, ll, int>> pxvi;

	auto solve = [&]() -> vector<double> {
		rep(i, n) {
			ll x, v;
			int idx;
			tie(x, v, idx) = xvi[i];
			if(x < 0 && v > 0) zxv.emplace_back(x, v);
			if(x > 0) pxvi.emplace_back(x, v, idx);
		}
		auto res = sol(zxv, pxvi, n);
		zxv.clear();
		pxvi.clear();

		return res;
	};

	auto r = solve();
	for(auto& [x, v, idx] : xvi) {
		x *= -1;
		v *= -1;
	}
	auto s = solve();
	cout << fixed << setprecision(15);
	rep(i, n) {
		r[i] = min(r[i], s[i]);
		if(r[i] > INF * 2 / 3) {
			cout << "-1\n";
		} else {
			cout << r[i] << '\n';
		}
	}
}
accuracy: 0.6774193548387096
time_ms: 1520
memory_kb: 26844
final_rank: 14

code_snippet: // verification-helper: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2975
// verification-helper: ERROR 1e-9

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif


#ifndef call_from_test
#include <bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
enum Objective{
  MINIMIZE = +1,
  MAXIMIZE = -1,
};

template<typename T> struct Line {
  T k,m;
  T operator()(const T x)const{return k*x+m;}
};

template <typename T, Objective objective>
struct ConvexHullTrick : deque<Line<T>>{
  inline int sgn(T x){return x==0?0:(x<0?-1:1);}

  using D = long double;
  inline bool check(const Line<T> &a,const Line<T> &b,const Line<T> &c){
    if(b.m==a.m||c.m==b.m)
      return sgn(b.k-a.k)*sgn(c.m-b.m) >= sgn(c.k-b.k)*sgn(b.m-a.m);
    // return (b.k-a.k)*(c.m-b.m) >= (b.m-a.m)*(c.k-b.k);
    return
      D(b.k-a.k)*sgn(c.m-b.m)/D(abs(b.m-a.m)) >=
      D(c.k-b.k)*sgn(b.m-a.m)/D(abs(c.m-b.m));
  }

  using super = deque<Line<T>>;
  using super::empty,super::size,super::front,super::back;
  using super::emplace_front,super::emplace_back;
  using super::pop_front,super::pop_back;
  const Line<T> at(int i) const{return (*this)[i];}

  void add(T k_,T m_){
    Line<T> l({k_*objective,m_*objective});
    if(empty()){
      emplace_front(l);
      return;
    }
    if(front().k<=l.k){
      if(front().k==l.k){
        if(front().m<=l.m) return;
        pop_front();
      }
      while(size()>=2 and check(l,at(0),at(1))) pop_front();
      emplace_front(l);
    }else{
      assert(l.k<=back().k);
      if(back().k==l.k){
        if(back().m<=l.m) return;
        pop_back();
      }
      while(size()>=2 and check(at(size()-2),at(size()-1),l)) pop_back();
      emplace_back(l);
    }
  }

  T query(T x){
    assert(!empty());
    int l=-1,r=size()-1;
    while(l+1<r){
      int m=(l+r)>>1;
      if(at(m)(x)>=at(m+1)(x)) l=m;
      else r=m;
    }
    return at(r)(x)*objective;
  }

  T queryMonotoneInc(T x){
    assert(!empty());
    while(size()>=2 and at(0)(x)>=at(1)(x)) pop_front();
    return front()(x)*objective;
  }

  T queryMonotoneDec(T x){
    assert(!empty());
    while(size()>=2 and at(size()-1)(x)>=at(size()-2)(x)) pop_back();
    return back()(x)*objective;
  }
};
template<typename T>
using MinConvexHullTrick = ConvexHullTrick<T, Objective::MINIMIZE>;
template<typename T>
using MaxConvexHullTrick = ConvexHullTrick<T, Objective::MAXIMIZE>;
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#undef call_from_test

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;

  int zx,zv;
  cin>>zx>>zv;

  vector<int> xs(n),vs(n);
  for(int i=0;i<n;i++) cin>>xs[i]>>vs[i];

  for(int i=0;i<n;i++){
    xs[i]-=zx;
    vs[i]-=zv;
  }

  using D = double;
  const D INF = 1e10;
  vector<D> ans(n,INF);
  for(int i=0;i<n;i++){
    if(xs[i]==0) ans[i]=0;
    if((D)xs[i]*(D)vs[i]<0) chmin(ans[i],-(D)xs[i]/(D)vs[i]);
  }

  for(int uku=0;uku<2;uku++){
    for(int i=0;i<n;i++){
      xs[i]*=-1;
      vs[i]*=-1;
    }

    using P = pair<D, D>;
    vector<P> vp;
    int sp=0;
    for(int i=0;i<n;i++){
      if(xs[i]>=0) continue;
      if(vs[i]<=0) continue;
      vp.emplace_back(vs[i],xs[i]);
      chmax(sp,vs[i]);
    }
    if(vp.empty()) continue;

    sort(vp.begin(),vp.end());
    MaxConvexHullTrick<D> cht;
    for(auto p:vp) cht.add(p.first,p.second);

    for(int i=0;i<n;i++){
      if(xs[i]<=0) continue;
      if(sp<=vs[i]) continue;
      D L=0,R=INF;
      for(int k=0;k<80;k++){
        D M=(L+R)/2;
        if(cht.query(M)>=(D)vs[i]*M+(D)xs[i]) R=M;
        else L=M;
      }
      chmin(ans[i],R);
    }
  }

  for(int i=0;i<n;i++){
    if(ans[i]>=INF) cout<<-1<<"\n";
    else cout<<ans[i]<<"\n";
  }
  return 0;
}
accuracy: 1
time_ms: 1310
memory_kb: 12024
final_rank: 5

code_snippet: #include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=2e5+7;
using tp=tuple<int,int,int>;
typedef double db;
tp pt[maxn];
struct L{
	ll a,b;
	inline db get(L x)
	{
		db tx=1.0*(b-x.b)/(x.a-a);
		return tx;
	}
	inline db val(db t)
	{
		return a*t+b;
	}
};
inline bool down(L a,L b, L c)
{
	return (a.a-b.a)*(c.b-b.b)>=(b.a-c.a)*(b.b-a.b);
}
struct ConvexHull{
	L dq[maxn];
	int sz;
	void clear(){sz=0;}
	void push(L x)
	{
		//while(sz>=2&&down(x,dq[sz],dq[sz-1])) sz--;//x.a递增
		while(sz>=2&&down(dq[sz-1],dq[sz],x)) sz--;//x.a递减
		dq[++sz]=x;
	}
	db get(L x)
	{
		ll L=1,R=sz,ret=-1;
		while(L<=R)
		{
			int mid=L+R>>1;
			if(mid==sz||dq[mid].get(x)<=dq[mid+1].get(x))
			{
				ret=mid;
				R=mid-1;
			}
			else L=mid+1;
		}
		return dq[ret].get(x);
	}
}q;
double ans[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	pi z;
	cin>>z.first>>z.second;
	for(int i=0;i<n;i++)
	{
		int x,v,id=i;
		cin>>x>>v;
		x-=z.first;
		v-=z.second;
		pt[i]={v,x,id};
		ans[i]=-1;
	}
	for(int _=0;_<2;_++)
	{
		sort(pt,pt+n,[&](tp a, tp b){
			int av,ax,aid,bv,bx,bid;tie(av,ax,aid)=a;
			tie(bv,bx,aid)=b;
			if(av==bv) return ax>bx;
			return av>bv;
		});
		bool isz=1;
		for(int i=0;i<n;i++)
		{
			int x,v,id;tie(v,x,id)=pt[i];
			if(v<0&&isz)
			{
				isz=0;
				q.push(L{0,0});
			}
			if(v>0&&x<0)
				q.push(L{v,x});
			if(x>0&&q.sz)
			{
				//dbg(id);
				ans[id]=q.get(L{v,x});
			}
		}
		q.clear();
		for(int i=0;i<n;i++)
		{
			int x,v,id;
			tie(v,x,id)=pt[i];
			pt[i]={-v,-x,id};
		}
	}
	for(int i=0;i<n;i++)
	{
		if(ans[i]<0) cout<<-1<<'\n';
		else cout<<fixed<<setprecision(14)<<ans[i]<<'\n';
	}
}
accuracy: 1
time_ms: 180
memory_kb: 10588
final_rank: 1

code_snippet: // verification-helper: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2975
// verification-helper: ERROR 1e-9

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif


#ifndef call_from_test
#include <bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
enum Objective{
  MINIMIZE = +1,
  MAXIMIZE = -1,
};

template<typename T> struct Line {
  T k,m;
  T operator()(const T x)const{return k*x+m;}
};

template <typename T, Objective objective>
struct ConvexHullTrick : deque<Line<T>>{
  inline int sgn(T x){return x==0?0:(x<0?-1:1);}

  using D = long double;
  inline bool check(const Line<T> &a,const Line<T> &b,const Line<T> &c){
    if(b.m==a.m||c.m==b.m)
      return sgn(b.k-a.k)*sgn(c.m-b.m) >= sgn(c.k-b.k)*sgn(b.m-a.m);
    // return (b.k-a.k)*(c.m-b.m) >= (b.m-a.m)*(c.k-b.k);
    return
      D(b.k-a.k)*sgn(c.m-b.m)/D(abs(b.m-a.m)) >=
      D(c.k-b.k)*sgn(b.m-a.m)/D(abs(c.m-b.m));
  }

  using super = deque<Line<T>>;
  using super::empty,super::size,super::front,super::back;
  using super::emplace_front,super::emplace_back;
  using super::pop_front,super::pop_back;
  const Line<T> at(int i) const{return (*this)[i];}

  void add(T k_,T m_){
    Line<T> l({k_*objective,m_*objective});
    if(empty()){
      emplace_front(l);
      return;
    }
    if(front().k<=l.k){
      if(front().k==l.k){
        if(front().m<=l.m) return;
        pop_front();
      }
      while(size()>=2 and check(l,at(0),at(1))) pop_front();
      emplace_front(l);
    }else{
      assert(l.k<=back().k);
      if(back().k==l.k){
        if(back().m<=l.m) return;
        pop_back();
      }
      while(size()>=2 and check(at(size()-2),at(size()-1),l)) pop_back();
      emplace_back(l);
    }
  }

  T query(T x){
    assert(!empty());
    int l=-1,r=size()-1;
    while(l+1<r){
      int m=(l+r)>>1;
      if(at(m)(x)>=at(m+1)(x)) l=m;
      else r=m;
    }
    return at(r)(x)*objective;
  }

  T queryMonotoneInc(T x){
    assert(!empty());
    while(size()>=2 and at(0)(x)>=at(1)(x)) pop_front();
    return front()(x)*objective;
  }

  T queryMonotoneDec(T x){
    assert(!empty());
    while(size()>=2 and at(size()-1)(x)>=at(size()-2)(x)) pop_back();
    return back()(x)*objective;
  }
};
template<typename T>
using MinConvexHullTrick = ConvexHullTrick<T, Objective::MINIMIZE>;
template<typename T>
using MaxConvexHullTrick = ConvexHullTrick<T, Objective::MAXIMIZE>;
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#undef call_from_test

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;

  int zx,zv;
  cin>>zx>>zv;

  vector<int> xs(n),vs(n);
  for(int i=0;i<n;i++) cin>>xs[i]>>vs[i];

  for(int i=0;i<n;i++){
    xs[i]-=zx;
    vs[i]-=zv;
  }

  using D = double;
  const D INF = 1e10;
  vector<D> ans(n,INF);
  for(int i=0;i<n;i++){
    if(xs[i]==0) ans[i]=0;
    if((D)xs[i]*(D)vs[i]<0) chmin(ans[i],-(D)xs[i]/(D)vs[i]);
  }

  for(int uku=0;uku<2;uku++){
    for(int i=0;i<n;i++){
      xs[i]*=-1;
      vs[i]*=-1;
    }

    using P = pair<D, D>;
    vector<P> vp;
    int sp=0;
    for(int i=0;i<n;i++){
      if(xs[i]>=0) continue;
      if(vs[i]<=0) continue;
      vp.emplace_back(vs[i],xs[i]);
      chmax(sp,vs[i]);
    }
    if(vp.empty()) continue;

    sort(vp.begin(),vp.end());
    MaxConvexHullTrick<D> cht;
    for(auto p:vp) cht.add(p.first,p.second);

    for(int i=0;i<n;i++){
      if(xs[i]<=0) continue;
      if(sp<=vs[i]) continue;
      D L=0,R=INF;
      for(int k=0;k<80;k++){
        D M=(L+R)/2;
        if(cht.query(M)>=(D)vs[i]*M+(D)xs[i]) R=M;
        else L=M;
      }
      chmin(ans[i],R);
    }
  }

  for(int i=0;i<n;i++){
    if(ans[i]>=INF) cout<<-1<<"\n";
    else cout<<ans[i]<<"\n";
  }
  return 0;
}
accuracy: 1
time_ms: 1310
memory_kb: 12264
final_rank: 6

code_snippet: #include<bits/stdc++.h>
using namespace std;

using ll=long long;
using dbl=double;

struct H{
    int id;
    ll x,v;
};
bool operator<(H lhs,H rhs){
    return lhs.x<rhs.x;
}
const dbl INF=1e22;
int n;
vector<dbl> ans;
H zombi;
vector<H> hs;
dbl calc(H x,H y){
    dbl ret=-dbl(y.x-x.x)/(y.v-x.v);
    if(ret<0) return INF;
    else return ret;
}
vector<H> cht(vector<H> &right){
    // cerr<<"$"<<right.size()<<endl;
    vector<H> res;
    for(auto h:right){
        while(res.size()>=2){
            int sz=res.size();
            H h1=res[sz-2],h2=res[sz-1],h3=h;
            if((h3.x-h2.x)*(h2.v-h1.v)<(h2.x-h1.x)*(h3.v-h2.v)) break;
            res.pop_back();
        }
        res.push_back(h);
    }
    // cerr<<"$"<<res.size()<<endl;
    return res;
}

void solve(){
    sort(hs.begin(),hs.end());
    vector<H> left;
    vector<H> right;
    right.push_back(zombi);
    for(auto h:hs){
        if(h.x<zombi.x) left.push_back(h);
        else{
            if(h.v<right.back().v) right.push_back(h);
        }
    }
    
    vector<H> chv=cht(right);
    // cerr<<chv.size()<<endl;

    for(auto h:left){
        int lb=-1,ub=chv.size()-1;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if(chv[mid].v-h.v>=0) lb=mid;
            else ub=mid;
        }
        lb++;
        ub=(int)chv.size()-1;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if(calc(h,chv[mid])>=calc(h,chv[mid+1])) lb=mid;
            else ub=mid;
        }
        // cerr<<"#"<<h.id<<" "<<lb<<endl;
        if(lb>=chv.size()){
            ans[h.id]=-1;
        }
        else ans[h.id]=min(calc(h,chv[lb]),(lb+1<chv.size() ? calc(h,chv[lb+1]) : INF));
    }
    return;
}

int main(){
    cin>>n;
    ans.assign(n,-1);
    hs.resize(n);
    cin>>zombi.x>>zombi.v;
    for(int i=0;i<n;i++){
        hs[i].id=i;
        cin>>hs[i].x>>hs[i].v;
    }
    
    solve();
    // inverse
    zombi.x=-zombi.x,zombi.v=-zombi.v;
    for(int i=0;i<n;i++) hs[i].x=-hs[i].x,hs[i].v=-hs[i].v;
    solve();
    cout<<setprecision(10)<<fixed;
    for(int i=0;i<n;i++){
        if(ans[i]==-1 || ans[i]>=INF) cout<<-1<<endl;
        else cout<<ans[i]<<endl;
    }
    return 0;
}
accuracy: 1
time_ms: 450
memory_kb: 19112
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;

using ld=long double;

signed main(){
  int N;cin>>N;
  int xz,vz;cin>>xz>>vz;
  std::vector<ld> x(N),v(N);
  for(int i=0;i<N;i++)cin>>x[i]>>v[i];
  for(int i=0;i<N;i++)x[i]-=xz,v[i]-=vz;
  //v>0,x<0の奴を使って折れ線を作る
  typedef pair<ld,ld> P;
  std::vector<P> w;
  for(int i=0;i<N;i++)if(v[i]>0&&x[i]<0)w.push_back(P(v[i],x[i]));
  sort(w.begin(),w.end());
  typedef pair<P,ld> PI;
  vector<PI> oresen;//これが使われ始める時間,場所,その傾き
  oresen.push_back(PI(P(0,0),0));
  for(int i=0;i<w.size();i++){
    ld V=w[i].first,X=w[i].second;
    if(i+1<w.size()&&w[i+1].first==V)continue;
    auto ite=oresen.rbegin();
    bool f=true;
    while(f){
      auto tmp=*ite;
      ld ti=tmp.first.first,po=tmp.first.second;
      if(X+ti*V>po){
        oresen.erase(oresen.rbegin().base());//計算量はならしなのでそんなに大きくはならない
        ite=oresen.rbegin();
      }
      else f=false;
    }
    auto tmp=*ite;
    ld ti=tmp.first.first,po=tmp.first.second,inc=tmp.second;
    ld newti=(po-X-ti*V)/(V-inc);
    ld T=ti+newti;
    oresen.push_back(PI(P(T,X+V*T),V));
  }
  std::vector<ld> ans(N);
  for(int i=0;i<N;i++){
    if(x[i]<0)continue;
    int l=0,r=oresen.size();
    while(r-l>1){
      int m=(l+r)>>1;
      ld ti=oresen[m].first.first,po=oresen[m].first.second;
      if(x[i]+v[i]*ti>=po)l=m;
      else r=m;
    }
    ld ti=oresen[l].first.first,po=oresen[l].first.second,inc=oresen[l].second;
    ld newti=(po-x[i]-ti*v[i])/(v[i]-inc);
    ans[i]=ti+newti;
  }


  //逆をやる　だいたいコピペ　全てのvとxを逆にしてやる
  for(int i=0;i<N;i++)v[i]*=-1,x[i]*=-1;
  std::vector<P> w2;
  for(int i=0;i<N;i++)if(v[i]>0&&x[i]<0)w2.push_back(P(v[i],x[i]));
  sort(w2.begin(),w2.end());
  //typedef pair<P,ld> PI;
  vector<PI> oresen2;//これが使われ始める時間,場所,その傾き
  oresen2.push_back(PI(P(0,0),0));
  for(int i=0;i<w2.size();i++){
    ld V=w2[i].first,X=w2[i].second;
    if(i+1<w2.size()&&w2[i+1].first==V)continue;
    auto ite=oresen2.rbegin();
    bool f=true;
    while(f){
      auto tmp=*ite;
      ld ti=tmp.first.first,po=tmp.first.second;
      if(X+ti*V>po){
        oresen2.erase(oresen2.rbegin().base());
        ite=oresen2.rbegin();
      }
      else f=false;
    }
    auto tmp=*ite;
    ld ti=tmp.first.first,po=tmp.first.second,inc=tmp.second;
    ld newti=(po-X-ti*V)/(V-inc);
    ld T=ti+newti;
    oresen2.push_back(PI(P(T,X+V*T),V));
  }
  //std::vector<ld> ans(N);
  for(int i=0;i<N;i++){
    if(x[i]<0)continue;
    int l=0,r=oresen2.size();
    while(r-l>1){
      int m=(l+r)>>1;
      ld ti=oresen2[m].first.first,po=oresen2[m].first.second;
      if(x[i]+v[i]*ti>=po)l=m;
      else r=m;
    }
    ld ti=oresen2[l].first.first,po=oresen2[l].first.second,inc=oresen2[l].second;
    ld newti=(po-x[i]-ti*v[i])/(v[i]-inc);
    ans[i]=ti+newti;
  }
  for(int i=0;i<N;i++)if(ans[i]<0)ans[i]=-1;
  for(int i=0;i<N;i++)cout<<fixed<<setprecision(12)<<ans[i]<<endl;
}
accuracy: 1
time_ms: 500
memory_kb: 32228
final_rank: 10

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

template<typename T, bool isMin>
struct ConvexHullTrick{
  #define F first
  #define S second
  using P = pair<T, T>;
  deque<P> H;

  bool empty()const{return H.empty();}
  void clear(){H.clear();}

  inline Int sgn(T x){return x == 0?0:(x<0? -1:1);}
  using D = long double;
  inline bool check(const P &a, const P &b, const P &c){
    if(b.S == a.S || c.S == b.S)
      return sgn(b.F - a.F) * sgn(c.S - b.S) >= sgn(c.F - b.F) * sgn(b.S - a.S);

    return
      D(b.F - a.F) * sgn(c.S - b.S)/D(abs(b.S - a.S)) >=
      D(c.F - b.F) * sgn(b.S - a.S)/D(abs(c.S - b.S));
  }

  void addLine(T m, T b){
    if(!isMin) m *= -1, b *= -1;
    P line(m, b);
    if(empty()){
      H.emplace_back(line);
      return;
    }

    if(H.front().F <= m){
      if(H.front().F == m){
        if(H.front().S <= b) return;
        H.pop_front();
      }
      while(H.size() >= 2 && check(line, H.front(), H[1])) H.pop_front();
      H.emplace_front(line);
    }else{
      assert(m <= H.back().F);
      if(H.back().F == m){
        if(H.back().S <= b) return;
        H.pop_back();
      }
      while(H.size() >= 2 && check(H[H.size() - 2], H.back(), line)) H.pop_back();
      H.emplace_back(line);
    }
  }

  inline T getY(const P &a, const T &x){
    return a.F * x + a.S;
  }

  T query(T x){
    assert(!empty());
    Int l = -1, r = H.size() - 1;
    while(l + 1 < r){
      Int m = (l + r) >> 1;
      if(getY(H[m], x) >= getY(H[m+1], x)) l = m;
      else r = m;
    }
    if(isMin) return getY(H[r], x);
    return - getY(H[r], x);
  }

#undef F
#undef S
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;

  Int zx,zv;
  cin>>zx>>zv;

  vector<Int> xs(n),vs(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>vs[i];

  for(Int i=0;i<n;i++){
    xs[i]-=zx;
    vs[i]-=zv;
  }

  using D = double;
  const D INF = 1e10;
  vector<D> ans(n,INF);
  for(Int i=0;i<n;i++){
    if(xs[i]==0) ans[i]=0;
    if((D)xs[i]*(D)vs[i]<0) chmin(ans[i],-(D)xs[i]/(D)vs[i]);
  }

  for(Int uku=0;uku<2;uku++){
    for(Int i=0;i<n;i++){
      xs[i]*=-1;
      vs[i]*=-1;
    }

    using P = pair<D, D>;
    vector<P> vp;
    Int sp=0;
    for(Int i=0;i<n;i++){
      if(xs[i]>=0) continue;
      if(vs[i]<=0) continue;
      vp.emplace_back(vs[i],xs[i]);
      chmax(sp,vs[i]);
    }
    if(vp.empty()) continue;

    sort(vp.begin(),vp.end());
    ConvexHullTrick<D, false> cht;
    for(auto p:vp) cht.addLine(p.first,p.second);

    for(Int i=0;i<n;i++){
      if(xs[i]<=0) continue;
      if(sp<=vs[i]) continue;
      D L=0,R=INF;
      for(Int k=0;k<80;k++){
        D M=(L+R)/2;
        if(cht.query(M)>=(D)vs[i]*M+(D)xs[i]) R=M;
        else L=M;
      }
      chmin(ans[i],R);
    }
  }

  cout<<fixed<<setprecision(12);
  for(Int i=0;i<n;i++){
    if(ans[i]>=INF) cout<<-1<<"\n";
    else cout<<ans[i]<<"\n";
  }
  cout<<flush;
  return 0;
}
accuracy: 1
time_ms: 1680
memory_kb: 11616
final_rank: 8

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

using R = double;
const R EPS = 1e-10;
int sgn(const R &r) { return (r>EPS) - (r<-EPS); }
int sgn(const R &a, const R &b) { return sgn(a-b); }

// 直線の傾きに単調性があるとき
template<typename T>
struct ConvexHullTrick {
    using P = pair<T,T>;
    deque<P> que;
    bool check(const P &a, const P &b, const P &c) {
        return sgn((b.first-a.first)*(c.second-b.second),(b.second-a.second)*(c.first-b.first)) >= 0;
    }
    T f(const P &p, T x) { return p.first * x + p.second; }
    // ax + b を追加
    void add(T a, T b) {
        P p(a, b);
        while(que.size() >= 2 && check(que[que.size()-2], que.back(), p)) {
            que.pop_back();
        }
        que.push_back(p);
    }
    // 単調性なし
    T query(T x) {
        int lb = -1, ub = que.size()-1;
        while(ub-lb > 1) {
            const int mid = (lb+ub)>>1;
            if(sgn(f(que[mid],x),f(que[mid+1],x))<=0) lb = mid;
            else ub = mid;
        }
        return f(que[ub], x);
    }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, xz, vz;
    cin >> n >> xz >> vz;
    vector<ll> xs(n), vs(n);
    REP(i, n) {
        cin >> xs[i] >> vs[i];
        xs[i] -= xz;
        vs[i] -= vz;
    }

    const R inf = 3e9;
    vector<R> ans(n, inf);
    REP(i, n) {
        if(xs[i] == 0) ans[i] = 0;
        if(xs[i]*vs[i]<0) chmin(ans[i], (R)xs[i]/vs[i]*-1);
    }

    auto solve = [&] {
        // 下側からスタートして傾きが正の人をchtに追加
        using P = pair<R,R>;
        vector<P> v;
        ll ma = 0;
        REP(i, n) {
            if(xs[i]>=0 || vs[i]<=0) continue;
            v.emplace_back(vs[i], xs[i]);
            chmax(ma, vs[i]);
        }
        if(v.size() == 0) return;
        ConvexHullTrick<R> cht;
        sort(ALL(v));
        for(auto p: v) cht.add(p.first, p.second);
        // 上側の人が一番最初に当たる時刻を求める
        REP(i, n) {
            if(xs[i] <= 0 || ma <= vs[i]) continue;
            R lb = 0, ub = inf;
            REP(j, 62) {
                const R mid = (lb+ub)/2;
                if(sgn(cht.query(mid),vs[i]*mid+xs[i]) >= 0) {
                    ub = mid;
                } else {
                    lb = mid;
                }
            }
            chmin(ans[i], ub);
        }
    };

    solve();
    REP(i, n) xs[i] *= -1, vs[i] *= -1;
    solve();

    cout << fixed << setprecision(12);
    REP(i, n) {
        if(ans[i] >= inf) cout << -1 << "\n";
        else cout << ans[i] << "\n";
    }
    cout << flush;

    return 0;
}
accuracy: 1
time_ms: 1600
memory_kb: 11564
final_rank: 7

code_snippet: #include <bits/stdc++.h>
 
 #define int long long
 #define pa pair<int,int>
  #define  mp make_pair
  #define  pb push_back
 using namespace std;




vector<pa> kouho;
vector<pair<double,pa>> conv;


bool hikaku(pa x,pa y){
	if(x.second!=y.second)return x.second<y.second;
	return x.first>y.first;
}

double kouten(pa t,pa s){
	return (s.first-t.first+0.0)/(t.second-s.second);
}

void make_conv(){
	sort(kouho.begin(),kouho.end(),hikaku);
	int n=kouho.size();
	
	conv.pb(mp(0.0,mp(0,0)));
	for(int i=1;i<n;i++)if(kouho[i].second>kouho[i-1].second){
		
		while(1){
			double kou=kouten(conv.back().second,kouho[i]);
			if(conv.back().first<kou){
				conv.pb(mp(kou,kouho[i]));
				break;
			}
			conv.pop_back();
		}
	}

}


double query(int x,int v){
	int n=conv.size();
	int si=0,ue=n;
	while(ue-si>1){
		int me=(ue+si)/2;
		if(conv[me].second.second<=v){
			si=me;
			continue;
		}
		double kou=kouten(mp(x,v),conv[me].second);
		if(kou>=conv[me].first) si=me;
		else ue=me;
	}
	double kotae=kouten(mp(x,v),conv[si].second);
	return kotae;
}


double ans[200020];
bool muri[200020]={};

 signed main(){
 	
 
    cin.tie(0);
	ios::sync_with_stdio(false);
	
 	int n;
 	cin>>n;
 	
 	int xx,vv;
 	cin>>xx>>vv;
 	vector<pa> ve(n);
 	for(int i=0;i<n;i++){
 		int y,yy;
 		cin>>y>>yy;
 		ve[i]=mp(y-xx,yy-vv);
 	}
 	kouho.pb(mp(0,0));
 	for(auto v:ve)if(v.first<0 && v.second>0)kouho.pb(v);
 	make_conv();
 	for(int i=0;i<n;i++)if(ve[i].first>0){
 		if(ve[i].second>=conv.back().second.second)muri[i]=1;
 		else ans[i]=query(ve[i].first,ve[i].second);
 	}
 	
 	kouho.clear();
 	conv.clear();
 	kouho.pb(mp(0,0));
 	
 	for(auto v:ve)if(v.first>0 && v.second<0){
 		pa w=v;
 		w.first*=-1,w.second*=-1;
 		kouho.pb(w);
 	}
 	make_conv();
 	for(int i=0;i<n;i++)if(ve[i].first<0){
 		if(-ve[i].second>=conv.back().second.second)muri[i]=1;
 		else ans[i]=query(-ve[i].first,-ve[i].second);
 	}
 	
 	for(int i=0;i<n;i++){
 		if(muri[i])printf("-1\n");
 		else{
 			printf("%.14lf\n",ans[i]);
 			if(ans[i]<0) exit(1);
 		}
 	}
return 0;

 }
accuracy: 1
time_ms: 170
memory_kb: 13844
final_rank: 2

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct Line {
	double a, b;
	Line(double a = 0, double b = -4e18) :a(a), b(b) {}
	double get(double x) { return a * x + b; }
};
bool cmp(Line& l, Line& r, double x) {
	if (l.a == r.a) return l.b >= r.b;
	if (l.a > r.a) return x >= (r.b - l.b) / (l.a - r.a);
	return x <= (r.b - l.b) / (l.a - r.a);
}
struct ConvexHullTrick {
	struct Node {
		Line l;
		Node *lhs, *rhs;
		Node(Line l) :l(l), lhs(nullptr), rhs(nullptr) {}
		Node() : lhs(nullptr), rhs(nullptr) {
			l = Line();
		}
	};
	const double mi = 0, ma = 1LL << 31;
	Node *root = nullptr;
	ConvexHullTrick() {}
	Node* insert(Node *p, double lb, double ub, Line& l) {
		if(!p) return new Node(l);
		if(cmp(p->l, l, lb) && cmp(p->l, l, ub)) return p;
		if(!cmp(p->l, l, lb) && !cmp(p->l, l, ub)) {
			p->l = l;
			return p;
		}
		double mid = (lb + ub) / 2;
		if (cmp(l, p->l, mid)) swap(p->l, l);
		if (cmp(l, p->l, lb)) p->lhs = insert(p->lhs, lb, mid, l);
		else p->rhs = insert(p->rhs, mid, ub, l);
		return p;
	}
	void insert(double a, double b) {
		Line l(a, b);
		root = insert(root, mi, ma, l);
	}
	double query(Node* p, double lb, double ub, double t) {
		if(!p) return -4e18;
		if(lb == ub) return p->l.get(t);
		double mid = (lb + ub) / 2;
		if(t <= mid) return max(p->l.get(t), query(p->lhs, lb, mid, t));
		return max(p->l.get(t), query(p->rhs, mid, ub, t));
	}
	double query(double x) { return query(root, mi, ma, x); }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;
    double xx, vv;
    cin >> xx >> vv;

    ConvexHullTrick upper, lower;
    upper.insert(-vv, -xx);
    lower.insert(vv, xx);

    vector<double> x(n), v(n);
    REP(i, n) {
        cin >> x[i] >> v[i];
        if(x[i] < xx) lower.insert(v[i], x[i]);
        else upper.insert(-v[i], -x[i]);
    }

    REP(i, n) {
        double lb=0, ub=1LL<<31;
        if(x[i] < xx) {
            REP(j, 64) {
                double mid = (lb+ub)/2;
                double ret = -upper.query(mid);
                if(v[i]*mid+x[i] >= ret) ub = mid;
                else lb = mid;
            }
            if(ub >= (1LL<<31)-1) cout << -1 << "\n";
            else cout << ub << "\n";
        } else {
            REP(j, 64) {
                double mid = (lb+ub)/2;
                double ret = lower.query(mid);
                if(v[i]*mid+x[i] <= ret) ub = mid;
                else lb = mid;
            }
            if(ub >= (1LL<<31)-1) cout << -1 << "\n";
            else cout << ub << "\n";
        }
    }

    return 0;
}
accuracy: 0.6774193548387096
time_ms: 1880
memory_kb: 15332
final_rank: 12

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

using R = double;
constexpr R EPS = 1E-11;
int sgn(const R& r){ return (r > EPS) - (r < -EPS); }
int sgn(const R& a, const R &b){ return sgn(a - b); }

// 単調性なしok 動的CHT 各操作O(logN)
template <typename T>
class ConvexHullTrick {
private:
    struct line {
        T a, b;
        line(T a_ = 0, T b_ = 0) : a(a_), b(b_) {}
        // ll でも overflow するのに注意
        T get(T x) { return a * x + b; }
    };
    struct node {
        line l;
        node *lch, *rch;
        node(line l_) : l(l_), lch(nullptr), rch(nullptr) {}
    };

    const T id, minx, maxx;
    node *root = nullptr;

    // [lb, ub]
    node* update(node *p, T lb, T ub, line& l) {
        if (!p) return new node(l);
        if (sgn(p->l.get(lb), l.get(lb))>=0 && sgn(p->l.get(ub), l.get(ub))>=0) return p;
        if (sgn(p->l.get(lb),l.get(lb))<=0 && sgn(p->l.get(ub),l.get(ub))<=0) {
          p->l = l;
          return p;
        }
        ll mid = (lb + ub) / 2;
        if(sgn(p->l.get(mid),l.get(mid))<0) swap(p->l, l);
        if(sgn(p->l.get(lb),l.get(lb))<=0) p->lch = update(p->lch, lb, mid, l);
        else p->rch = update(p->rch, mid + 1, ub, l);
        return p;
    }
    // [lb, ub]
    T query(node *p, T lb, T ub, T t) const {
        if(!p) return id;
        if(sgn(ub,lb)==0) return p->l.get(t);
        ll mid = (lb+ub)/2;
        if(sgn(t,mid)<=0) return max(p->l.get(t), query(p->lch, lb, mid, t));
        return max(p->l.get(t), query(p->rch, mid + 1, ub, t));
    }
public:
    // getで呼び出しうるxの範囲を指定
    ConvexHullTrick(const T minx_, const T maxx_) : id(numeric_limits<T>::min()), minx(minx_), maxx(maxx_) {}
    // 直線ax+bを追加 最小がほしければ-ax-bを渡してgetの結果に×(-1)する
    void insert(T a, T b) {
        line l(a, b);
        root = update(root, minx, maxx, l);
    }
    // ax+b のうち最大のものを返す
    T get(T x) const { return query(root, minx, maxx, x); }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, xz, vz;
    cin >> n >> xz >> vz;
    vector<ll> x(n), v(n);
    REP(i, n) {
        cin >> x[i] >> v[i];
        x[i] -= xz;
        v[i] -= vz;
    }

    // cout << "x:" << x << endl;
    // cout << "v:" << v << endl;

    vector<R> ans(n, -2);
    vector<ll> upper, lower;
    REP(i, n) {
        if(x[i] > 0) {
            upper.push_back(i);
        } else if(x[i] < 0) {
            lower.push_back(i);
        }
    }

    // cout << "lower:" << lower << endl;
    // cout << "upper:" << upper << endl;

    ll lmax = 0, umin = 0;
    for(auto i: lower) chmax(lmax, v[i]);
    for(auto i: upper) chmin(umin, v[i]);
    // cout << "lmax:" << lmax << " umin:" << umin << endl;
    for(auto i: lower) if(v[i] <= umin) ans[i] = -1;
    for(auto i: upper) if(v[i] >= lmax) ans[i] = -1;

    // upperの人がゾンビになる時間
    {
        ConvexHullTrick<R> cht(0, 1100000000);
        cht.insert(0, 0);
        for(auto i: lower) cht.insert(v[i], x[i]);

        for(auto i: upper) {
            if(ans[i] == -1) continue;
            auto check = [&](R mid) {
                return sgn(cht.get(mid), v[i] * mid + x[i]) >= 0;
            };
            R lb = 0, ub = 1.1e9;
            REP(j, 62) {
                R mid = (lb+ub)/2;
                if(check(mid)) ub = mid;
                else lb = mid;
            }
            ans[i] = lb;
        }
    }

    // lowerの人がゾンビになる時間
    {
        ConvexHullTrick<R> cht(0, 1100000000);
        cht.insert(0, 0);
        for(auto i: upper) cht.insert(-v[i], -x[i]);

        for(auto i: lower) {
            if(ans[i] == -1) continue;
            auto check = [&](R mid) {
                return sgn(-cht.get(mid), v[i] * mid + x[i]) <= 0;
            };
            R lb = 0, ub = 1.1e9;
            REP(j, 62) {
                R mid = (lb+ub)/2;
                if(check(mid)) ub = mid;
                else lb = mid;
            }
            ans[i] = lb;
        }
    }

    REP(i, n) cout << fixed << setprecision(15) << ans[i] << '\n';

    return 0;
}
accuracy: 0.3548387096774194
time_ms: 1710
memory_kb: 9420
final_rank: 17

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

using R = double;
constexpr R EPS = 1E-10;
int sgn(const R& r){ return (r > EPS) - (r < -EPS); }
int sgn(const R& a, const R &b){ return sgn(a - b); }

// 単調性なしok 動的CHT 各操作O(logN)
template <typename T>
class ConvexHullTrick {
private:
    struct line {
        T a, b;
        line(T a_ = 0, T b_ = 0) : a(a_), b(b_) {}
        // ll でも overflow するのに注意
        T get(T x) { return a * x + b; }
    };
    struct node {
        line l;
        node *lch, *rch;
        node(line l_) : l(l_), lch(nullptr), rch(nullptr) {}
    };

    const T id, minx, maxx;
    node *root = nullptr;

    // [lb, ub]
    node* update(node *p, T lb, T ub, line& l) {
        if (!p) return new node(l);
        if (sgn(p->l.get(lb), l.get(lb))>=0 && sgn(p->l.get(ub), l.get(ub))>=0) return p;
        if (sgn(p->l.get(lb),l.get(lb))<=0 && sgn(p->l.get(ub),l.get(ub))<=0) {
          p->l = l;
          return p;
        }
        ll mid = (lb + ub) / 2;
        if(sgn(p->l.get(mid),l.get(mid))<0) swap(p->l, l);
        if(sgn(p->l.get(lb),l.get(lb))<=0) p->lch = update(p->lch, lb, mid, l);
        else p->rch = update(p->rch, mid + 1, ub, l);
        return p;
    }
    // [lb, ub]
    T query(node *p, T lb, T ub, T t) const {
        if(!p) return id;
        if(sgn(ub,lb)==0) return p->l.get(t);
        ll mid = (lb+ub)/2;
        if(sgn(t,mid)<=0) return max(p->l.get(t), query(p->lch, lb, mid, t));
        return max(p->l.get(t), query(p->rch, mid + 1, ub, t));
    }
public:
    // getで呼び出しうるxの範囲を指定
    ConvexHullTrick(const T minx_, const T maxx_) : id(numeric_limits<T>::min()), minx(minx_), maxx(maxx_) {}
    // 直線ax+bを追加 最小がほしければ-ax-bを渡してgetの結果に×(-1)する
    void insert(T a, T b) {
        line l(a, b);
        root = update(root, minx, maxx, l);
    }
    // ax+b のうち最大のものを返す
    T get(T x) const { return query(root, minx, maxx, x); }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, xz, vz;
    cin >> n >> xz >> vz;
    vector<ll> x(n), v(n);
    REP(i, n) {
        cin >> x[i] >> v[i];
        x[i] -= xz;
        v[i] -= vz;
    }

    // cout << "x:" << x << endl;
    // cout << "v:" << v << endl;

    vector<R> ans(n, -2);
    vector<ll> upper, lower;
    REP(i, n) {
        if(x[i] > 0) {
            upper.push_back(i);
        } else if(x[i] < 0) {
            lower.push_back(i);
        }
    }

    // cout << "lower:" << lower << endl;
    // cout << "upper:" << upper << endl;

    ll lmax = 0, umin = 0;
    for(auto i: lower) chmax(lmax, v[i]);
    for(auto i: upper) chmin(umin, v[i]);
    // cout << "lmax:" << lmax << " umin:" << umin << endl;
    for(auto i: lower) if(v[i] <= umin) ans[i] = -1;
    for(auto i: upper) if(v[i] >= lmax) ans[i] = -1;

    // upperの人がゾンビになる時間
    {
        ConvexHullTrick<R> cht(0, 1100000000);
        cht.insert(0, 0);
        for(auto i: lower) cht.insert(v[i], x[i]);

        for(auto i: upper) {
            if(ans[i] == -1) continue;
            auto check = [&](R mid) {
                return sgn(cht.get(mid), v[i] * mid + x[i]) >= 0;
            };
            R lb = 0, ub = 1.1e9;
            REP(j, 62) {
                R mid = (lb+ub)/2;
                if(check(mid)) ub = mid;
                else lb = mid;
            }
            ans[i] = lb;
        }
    }

    // lowerの人がゾンビになる時間
    {
        ConvexHullTrick<R> cht(0, 1100000000);
        cht.insert(0, 0);
        for(auto i: upper) cht.insert(-v[i], -x[i]);

        for(auto i: lower) {
            if(ans[i] == -1) continue;
            auto check = [&](R mid) {
                return sgn(-cht.get(mid), v[i] * mid + x[i]) <= 0;
            };
            R lb = 0, ub = 1.1e9;
            REP(j, 62) {
                R mid = (lb+ub)/2;
                if(check(mid)) ub = mid;
                else lb = mid;
            }
            ans[i] = lb;
        }
    }

    REP(i, n) cout << fixed << setprecision(15) << ans[i] << '\n';

    return 0;
}
accuracy: 0.3548387096774194
time_ms: 1710
memory_kb: 9512
final_rank: 18

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

using R = double;
constexpr R EPS = 1E-10;
int sgn(const R& r){ return (r > EPS) - (r < -EPS); }
int sgn(const R& a, const R &b){ return sgn(a - b); }

// 単調性なしok 動的CHT 各操作O(logN)
template <typename T>
class ConvexHullTrick {
private:
    struct line {
        T a, b;
        line(T a_ = 0, T b_ = 0) : a(a_), b(b_) {}
        // ll でも overflow するのに注意
        T get(T x) { return a * x + b; }
    };
    struct node {
        line l;
        node *lch, *rch;
        node(line l_) : l(l_), lch(nullptr), rch(nullptr) {}
    };

    const T id, minx, maxx;
    node *root = nullptr;

    // [lb, ub]
    node* update(node *p, T lb, T ub, line& l) {
        if (!p) return new node(l);
        if (sgn(p->l.get(lb), l.get(lb))>=0 && sgn(p->l.get(ub), l.get(ub))>=0) return p;
        if (sgn(p->l.get(lb),l.get(lb))<=0 && sgn(p->l.get(ub),l.get(ub))<=0) {
          p->l = l;
          return p;
        }
        ll mid = (lb + ub) / 2;
        if(sgn(p->l.get(mid),l.get(mid))<0) swap(p->l, l);
        if(sgn(p->l.get(lb),l.get(lb))<=0) p->lch = update(p->lch, lb, mid, l);
        else p->rch = update(p->rch, mid + 1, ub, l);
        return p;
    }
    // [lb, ub]
    T query(node *p, T lb, T ub, T t) const {
        if(!p) return id;
        if(sgn(ub,lb)==0) return p->l.get(t);
        ll mid = (lb+ub)/2;
        if(sgn(t,mid)<=0) return max(p->l.get(t), query(p->lch, lb, mid, t));
        return max(p->l.get(t), query(p->rch, mid + 1, ub, t));
    }
public:
    // getで呼び出しうるxの範囲を指定
    ConvexHullTrick(const T minx_, const T maxx_) : id(numeric_limits<T>::min()), minx(minx_), maxx(maxx_) {}
    // 直線ax+bを追加 最小がほしければ-ax-bを渡してgetの結果に×(-1)する
    void insert(T a, T b) {
        line l(a, b);
        root = update(root, minx, maxx, l);
    }
    // ax+b のうち最大のものを返す
    T get(T x) const { return query(root, minx, maxx, x); }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, xz, vz;
    cin >> n >> xz >> vz;
    vector<ll> x(n), v(n);
    REP(i, n) {
        cin >> x[i] >> v[i];
        x[i] -= xz;
        v[i] -= vz;
    }

    // cout << "x:" << x << endl;
    // cout << "v:" << v << endl;

    vector<R> ans(n, -2);
    vector<ll> upper, lower;
    REP(i, n) {
        if(x[i] > 0) {
            upper.push_back(i);
        } else if(x[i] < 0) {
            lower.push_back(i);
        }
    }

    // cout << "lower:" << lower << endl;
    // cout << "upper:" << upper << endl;

    ll lmax = 0, umin = 0;
    for(auto i: lower) chmax(lmax, v[i]);
    for(auto i: upper) chmin(umin, v[i]);
    // cout << "lmax:" << lmax << " umin:" << umin << endl;
    for(auto i: lower) if(v[i] <= umin) ans[i] = -1;
    for(auto i: upper) if(v[i] >= lmax) ans[i] = -1;

    // upperの人がゾンビになる時間
    {
        ConvexHullTrick<R> cht(0, 1100000000);
        cht.insert(0, 0);
        for(auto i: lower) cht.insert(v[i], x[i]);

        for(auto i: upper) {
            if(ans[i] == -1) continue;
            auto check = [&](R mid) {
                return sgn(cht.get(mid), v[i] * mid + x[i]) >= 0;
            };
            R lb = 0, ub = 1.1e9;
            REP(j, 62) {
                R mid = (lb+ub)/2;
                if(check(mid)) ub = mid;
                else lb = mid;
            }
            ans[i] = lb;
        }
    }

    // lowerの人がゾンビになる時間
    {
        ConvexHullTrick<R> cht(0, 1100000000);
        cht.insert(0, 0);
        for(auto i: upper) cht.insert(-v[i], -x[i]);

        for(auto i: lower) {
            if(ans[i] == -1) continue;
            auto check = [&](R mid) {
                return sgn(-cht.get(mid), v[i] * mid + x[i]) <= 0;
            };
            R lb = 0, ub = 1.1e9;
            REP(j, 62) {
                R mid = (lb+ub)/2;
                if(check(mid)) ub = mid;
                else lb = mid;
            }
            ans[i] = lb;
        }
    }

    REP(i, n) cout << fixed << setprecision(15) << ans[i] << endl;

    return 0;
}
accuracy: 0.3548387096774194
time_ms: 1870
memory_kb: 9492
final_rank: 19

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

// 単調性なしok 動的CHT 各操作O(logN)
template <typename T>
class ConvexHullTrick {
private:
    struct line {
        T a, b;
        line(T a_ = 0, T b_ = 0) : a(a_), b(b_) {}
        // ll でも overflow するのに注意
        T get(T x) { return a * x + b; }
    };
    struct node {
        line l;
        node *lch, *rch;
        node(line l_) : l(l_), lch(nullptr), rch(nullptr) {}
    };

    const T id, minx, maxx;
    node *root = nullptr;

    // [lb, ub]
    node* update(node *p, T lb, T ub, line& l) {
        if (!p) return new node(l);
        if (p->l.get(lb) >= l.get(lb) && p->l.get(ub) >= l.get(ub)) return p;
        if (p->l.get(lb) <= l.get(lb) && p->l.get(ub) <= l.get(ub)) {
          p->l = l;
          return p;
        }
        ll mid = (lb + ub) / 2;
        if (p->l.get(mid) < l.get(mid)) swap(p->l, l);
        if (p->l.get(lb) <= l.get(lb)) p->lch = update(p->lch, lb, mid, l);
        else p->rch = update(p->rch, mid + 1, ub, l);
        return p;
    }
    // [lb, ub]
    T query(node *p, T lb, T ub, T t) const {
        if(!p) return id;
        if(ub == lb) return p->l.get(t);
        ll mid = (lb+ub)/2;
        if(t <= mid) return max(p->l.get(t), query(p->lch, lb, mid, t));
        return max(p->l.get(t), query(p->rch, mid + 1, ub, t));
    }
public:
    // getで呼び出しうるxの範囲を指定
    ConvexHullTrick(const T minx_, const T maxx_) : id(numeric_limits<T>::min()), minx(minx_), maxx(maxx_) {}
    // 直線ax+bを追加 最小がほしければ-ax-bを渡してgetの結果に×(-1)する
    void insert(T a, T b) {
        line l(a, b);
        root = update(root, minx, maxx, l);
    }
    // ax+b のうち最大のものを返す
    T get(T x) const { return query(root, minx, maxx, x); }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, xz, vz;
    cin >> n >> xz >> vz;
    vector<ll> x(n), v(n);
    REP(i, n) {
        cin >> x[i] >> v[i];
        x[i] -= xz;
        v[i] -= vz;
    }

    // cout << "x:" << x << endl;
    // cout << "v:" << v << endl;

    vector<double> ans(n, -2);
    vector<ll> upper, lower;
    REP(i, n) {
        if(x[i] > 0) {
            upper.push_back(i);
        } else if(x[i] < 0) {
            lower.push_back(i);
        }
    }

    // cout << "lower:" << lower << endl;
    // cout << "upper:" << upper << endl;

    ll lmax = 0, umin = 0;
    for(auto i: lower) chmax(lmax, v[i]);
    for(auto i: upper) chmin(umin, v[i]);
    // cout << "lmax:" << lmax << " umin:" << umin << endl;
    for(auto i: lower) if(v[i] <= umin) ans[i] = -1;
    for(auto i: upper) if(v[i] >= lmax) ans[i] = -1;

    // upperの人がゾンビになる時間
    {
        ConvexHullTrick<double> cht(0, 1100000000);
        cht.insert(0, 0);
        for(auto i: lower) cht.insert(v[i], x[i]);

        for(auto i: upper) {
            if(ans[i] == -1) continue;
            auto check = [&](double mid) {
                return cht.get(mid) >= v[i] * mid + x[i];
            };
            double lb = 0, ub = 1.1e9;
            REP(j, 70) {
                double mid = (lb+ub)/2;
                if(check(mid)) ub = mid;
                else lb = mid;
            }
            ans[i] = lb;
        }
    }

    // lowerの人がゾンビになる時間
    {
        ConvexHullTrick<double> cht(0, 1100000000);
        cht.insert(0, 0);
        for(auto i: upper) cht.insert(-v[i], -x[i]);

        for(auto i: lower) {
            if(ans[i] == -1) continue;
            auto check = [&](double mid) {
                return -cht.get(mid) <= v[i] * mid + x[i];
            };
            double lb = 0, ub = 1.1e9;
            REP(j, 70) {
                double mid = (lb+ub)/2;
                if(check(mid)) ub = mid;
                else lb = mid;
            }
            ans[i] = lb;
        }
    }

    REP(i, n) cout << fixed << setprecision(15) << ans[i] << endl;

    return 0;
}
accuracy: 0.3548387096774194
time_ms: 1940
memory_kb: 9604
final_rank: 20

code_snippet: #include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
using namespace std;
typedef double ll;
//const ll mod = 1000000007;
//const ll INF = mod * mod;
typedef pair<ll, ll> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa; cin>>nyaa;
const ll eps = 1e-2;
struct Line {
	ll a, b;
	Line(ll a = 0, ll b = -4e18) :a(a), b(b) {}
	ll get(ll x) {
		return a * x + b;
	}

};
bool cmp(Line& l, Line& r, ll x) {
	if (l.a == r.a)return l.b >= r.b;
	if (l.a > r.a)return x >= (r.b - l.b) / (l.a - r.a);
	return x <= (r.b - l.b) / (l.a - r.a);

}
Line chmax(Line& l, Line r, ll x) {
	if (cmp(l, r, x))return l;
	else return r;
}
struct ConvexHullTrick {

	struct Node {
		Line l;
		Node *lhs, *rhs;
		Node(Line l) :l(l), lhs(nullptr), rhs(nullptr) {}
		Node() : lhs(nullptr), rhs(nullptr) {
			l = Line();
		}

	};
	const ll mi = 0, ma = 1LL << 31;
	Node *root = nullptr;
	ConvexHullTrick() {}
	Node* insert(Node *p, ll lb, ll ub, Line& l) {
		if (!p)return new Node(l);
		if (cmp(p->l, l, lb) && cmp(p->l, l, ub))return p;
		if (!cmp(p->l, l, lb) && !cmp(p->l, l, ub)) {
			p->l = l;
			return p;
		}
		ll mid = (lb + ub) / 2;
		if (cmp(l, p->l, mid))swap(p->l, l);
		if (cmp(l, p->l, lb)) {
			p->lhs = insert(p->lhs, lb, mid, l);
		}
		else {
			p->rhs = insert(p->rhs, mid, ub, l);

		}
		return p;
	}
	void insert(ll a, ll b) {
		Line l(a, b);
		root = insert(root, mi, ma, l);
	}
	ll query(Node* p, ll lb, ll ub, ll t) {
		if (!p)return -4e18;
		if (lb == ub)return p->l.get(t);
		ll mid = (lb + ub) / 2;
		if (t <= mid)return max(p->l.get(t), query(p->lhs, lb, mid, t));
		else return max(p->l.get(t), query(p->rhs, mid, ub, t));

	}
	ll query(ll x) {
		return query(root, mi, ma, x);
	}
	Line query2(Node* p, ll lb, ll ub, ll t) {
		if (!p)return Line{ 0,-4e18 };
		if (lb == ub)return p->l;
		ll mid = (lb + ub) / 2;
		if (t <= mid)return chmax(p->l, query2(p->lhs, lb, mid, t), t);
		else return chmax(p->l, query2(p->rhs, mid, ub, t), t);

	}
	Line query2(ll x) {
		return query2(root, mi, ma, x);
	}
};

void solve() {
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	ll xx, vv;
	cin >> xx >> vv;
	ConvexHullTrick lc, rc;
	rc.insert(-vv, -xx);
	lc.insert(vv, xx);
	vector<ll> x(n), v(n);
	rep(i, n) {
		cin >> x[i] >> v[i];
		if (x[i] < xx) {
			lc.insert(v[i], x[i]);
		}
		else {
			rc.insert(-v[i], -x[i]);
		}
	}
	rep(i, n) {

		ll ok = 1LL << 31, ng = 0;
		if (x[i] < xx) {
			rep(_, 64) {
				ll mid = (ok + ng) / 2;
				ll ret = -rc.query(mid);
				if (v[i] * mid + x[i] >= ret)ok = mid;
				else ng = mid;
			}
			if (ok >= (1LL << 31) - 1)cout << -1 << "\n";
			else {
				auto ret = rc.query2(ok);
				//cout << ret.a << endl;
				cout << abs((x[i] + ret.b) / (ret.a + v[i])) << "\n";
			}
		}
		else {
			rep(_, 64) {
				ll mid = (ok + ng) / 2;
				ll ret = lc.query(mid);
				if (v[i] * mid + x[i] <= ret)ok = mid;
				else ng = mid;
			}
			if (ok >= (1LL << 31) - 1)cout << -1 << "\n";
			else {
				auto ret = lc.query2(ok);
				//cout << ok << endl;
				//cout << ret.a <<" "<<ret.b << endl;
				cout << abs((x[i] - ret.b) / (v[i] - ret.a)) << "\n";
			}
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
	return 0;
}
accuracy: 1
time_ms: 1960
memory_kb: 15368
final_rank: 11

code_snippet: #include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <numeric>
#include <tuple>
#include <functional>
#include <limits>

template <typename Tp>
class envelope {
  using size_type = size_t;
  using value_type = Tp;

private:
  using interval_type = std::pair<value_type, value_type>;
  using line_type = std::pair<value_type, value_type>;
  std::map<interval_type, line_type> M_lines;
  std::map<line_type, interval_type, std::greater<>> M_intervals;
  static value_type constexpr S_min = std::numeric_limits<value_type>::min();
  static value_type constexpr S_max = std::numeric_limits<value_type>::max();

  static value_type S_floor(value_type x, value_type y) {
    return x / y;
  }

  static value_type S_ceil(value_type x, value_type y) {
    return x / y;
  }

public:
  envelope() = default;
  envelope(envelope const&) = default;
  envelope(envelope&&) = default;
  envelope& operator =(envelope const&) = default;
  envelope& operator =(envelope&&) = default;

  bool push(value_type const& a, value_type const& b) {
    if (M_lines.empty()) {
      M_lines[interval_type(S_min, S_max)] = line_type(a, b);
      M_intervals[line_type(a, b)] = interval_type(S_min, S_max);
      return true;
    }

    auto it = M_intervals.lower_bound(line_type(a, S_min));
    value_type lb = S_min;
    value_type ub = S_max;

    auto it1 = it;
    if (it != M_intervals.end() && it->first.first == a) {
      if (it->first.second <= b) return false;
      M_lines.erase(it->second);
      it1 = M_intervals.erase(it);
    }

    auto it0 = M_intervals.end();
    if (it != M_intervals.begin()) it0 = std::prev(it);

    if (it0 != M_intervals.end()) {
      value_type a0, b0;
      std::tie(a0, b0) = it0->first;
      lb = S_ceil(b-b0, -(a-a0));
    }
    if (it1 != M_intervals.end()) {
      value_type a1, b1;
      std::tie(a1, b1) = it1->first;
      ub = S_floor(b1-b, -(a1-a));
    }

    if (ub < lb) return false;

    if (it0 != M_intervals.end()) {
      while (lb <= it0->second.first) {
        M_lines.erase(it0->second);
        it0 = M_intervals.erase(it0);
        if (it0 == M_intervals.begin()) {
          it0 = M_intervals.end();
          break;
        }
        --it0;
        value_type a0, b0;
        std::tie(a0, b0) = it0->first;
        lb = S_ceil(b-b0, -(a-a0));
      }
    }

    while (it1 != M_intervals.end() && it1->second.second <= ub) {
      M_lines.erase(it1->second);
      it1 = M_intervals.erase(it1);
      value_type a1, b1;
      std::tie(a1, b1) = it1->first;
      ub = S_floor(b1-b, -(a1-a));
    }

    if (it0 != M_intervals.end()) {
      value_type a0, b0, l0, u0;
      std::tie(a0, b0) = it0->first;
      std::tie(l0, u0) = it0->second;
      it0->second.second = std::min(u0, lb);  // !?!?
      M_lines.erase(interval_type(l0, u0));
      M_lines[it0->second] = it0->first;
    }
    if (it1 != M_intervals.end()) {
      value_type a1, b1, l1, u1;
      std::tie(a1, b1) = it1->first;
      std::tie(l1, u1) = it1->second;
      it1->second.first = std::max(l1, ub);  // !?!?
      M_lines.erase(interval_type(l1, u1));
      M_lines[it1->second] = it1->first;
    }

    M_lines[interval_type(lb, ub)] = line_type(a, b);
    M_intervals[line_type(a, b)] = interval_type(lb, ub);

    return true;
  }

  value_type min(value_type const& x) {
    value_type a, b;
    value_type res = S_max;
    auto it = M_lines.upper_bound(interval_type(x, S_max));
    if (it != M_lines.end()) {
      std::tie(a, b) = it->second;
      res = std::min(res, a*x + b);
      {
        auto it1 = std::next(it);
        if (it1 != M_lines.end()) {
          std::tie(a, b) = it1->second;
          res = std::min(res, a*x + b);
        }
      }
    }
    if (it != M_lines.begin()) {
      --it;
      std::tie(a, b) = it->second;
      res = std::min(res, a*x + b);
    }
    if (it != M_lines.begin()) {
      --it;
      std::tie(a, b) = it->second;
      res = std::min(res, a*x + b);
    }

    return res;

    // std::tie(a, b) = (--M_lines.upper_bound(interval_type(x, S_max)))->second;
    // // fprintf(stderr, "%f %f + %f = %f\n", a, x, b, a*x+b);
    // return a*x + b;
  }

  void inspect() const {
    for (auto const& p: M_lines) {
      fprintf(stderr, "[%f, %f]: %f x + %f\n",
              p.first.first, p.first.second,
              p.second.first, p.second.second);
    }
    for (auto const& p: M_intervals) {
      fprintf(stderr, "[%f, %f]: %f x + %f\n",
              p.second.first, p.second.second,
              p.first.first, p.first.second);
    }
  }
};

template <typename Tp> Tp constexpr envelope<Tp>::S_min;
template <typename Tp> Tp constexpr envelope<Tp>::S_max;

void neko(std::vector<double>& res,
          std::vector<std::tuple<int, int, size_t>> const& red,
          std::vector<std::tuple<int, int, size_t>> const& blue) {

  envelope<double> ev;
  for (auto const& p: blue) {
    int x, v;
    std::tie(x, v, std::ignore) = p;
    ev.push(v, x);
  }
  // ev.inspect();
  for (auto const& p: red) {
    int x, v;
    size_t i;
    std::tie(x, v, i) = p;

    double inf = 1e10;
    res[i] = inf;

    double lb = 0;
    double ub = inf;
    // fprintf(stderr, "%zu-th person\n", i);
    for (int k = 0; k < 90; ++k) {
      double mid = 0.5*(lb+ub);
      double x0 = ev.min(mid);
      double x1 = x + v*mid;
      // fprintf(stderr, "mid: %.12f, x0: %.12f, x1: %.12f\n", mid, x0, x1);
      ((x0 < x1)? ub: lb) = mid;
    }

    if (lb < inf/2) {
      res[i] = lb;
    }
    if (v > 0) {
      res[i] = std::min(res[i], -double(x)/v);
    }
    if (res[i] > inf/2) {
      res[i] = -1;
    }
  }
}

int main() {
  size_t n;
  scanf("%zu", &n);

  int xz, vz;
  scanf("%d %d", &xz, &vz);

  std::vector<std::tuple<int, int, size_t>> red, blue;
  red.reserve(n);
  blue.reserve(n);
  for (size_t i = 0; i < n; ++i) {
    int x, v;
    scanf("%d %d", &x, &v);
    v -= vz;
    x -= xz;

    if (x > 0) {
      blue.emplace_back(x, v, i);
    } else {
      red.emplace_back(x, v, i);
    }
  }

  std::vector<double> res(n, -1);
  neko(res, red, blue);
  for (auto& p: red) {
    int x, v;
    size_t i;
    std::tie(x, v, i) = p;
    p = std::make_tuple(-x, -v, i);
  }
  for (auto& p: blue) {
    int x, v;
    size_t i;
    std::tie(x, v, i) = p;
    p = std::make_tuple(-x, -v, i);
  }
  neko(res, blue, red);

  for (size_t i = 0; i < n; ++i) {
    if (res[i] == -1) {
      puts("-1");
    } else {
      printf("%.12f\n", res[i]);
    }
  }
}
accuracy: 0.6774193548387096
time_ms: 1350
memory_kb: 22728
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define DEBUG(x) cerr << #x << ": " << (x) << endl
#define EPS 1e-11

using ll = long long;

int n;
ll xz, vz;
ll x[252521], v[252521];
long double ans[252521];

using P = complex<long double>;

long double dot(P a, P b){return real(conj(a)*b);}
long double cross(P a, P b){return imag(conj(a)*b);}

P getCP(P a1, P a2, P b1, P b2){
	P a = a2-a1;
	P b = b2-b1;
	return a1 + a * cross(b,b1-a1) / cross(b,a);
}

bool hitHL(P s1, P v1, P s2, P v2){
	P cp = getCP(s1, s1+v1, s2, s2+v2);
	// puts("");
	// DEBUG(real(v1));
	// DEBUG(imag(v1));
	// DEBUG(real(cp));
	// DEBUG(imag(cp));
	cp = (cp - s1) / v1;
	// cp /= v1;
	// DEBUG(real(cp));
	// DEBUG(imag(cp));
	return real(cp) >= -EPS;
}
int hitHL2(P s1, P t1, P s2, P v2){
	P cp = getCP(s1, t1, s2, s2+v2);
	cp = (cp - s1) / (t1 - s1);
	// cp /= (t1-s1);
	if(real(cp)<-EPS)return -1;
	if(real(cp)>1+EPS)return 1;
	return 0;
}

void solve(vector<int> cvx, vector<int> acc){
	sort(cvx.begin(), cvx.end(), [&](int i, int j){
		if(x[i] != x[j])return x[i] > x[j];
		return v[i] > v[j];
	});
	vector<P> conv;
	P lastvec = P(vz, 1);
	conv.push_back(P(xz, 0));
	REP(i,cvx.size()){
		int idx = cvx[i];
		// DEBUG(idx);
		if(lastvec.real() >= v[idx]-EPS){
			// slow
			continue;
		}
		if(x[idx] == vz){
			lastvec = P(v[idx], 1);
			continue;
		}
		P pp = P(x[idx],0);
		P vv = P(v[idx],1);
		// conv
		while(conv.size() > 0){
			P beg = conv.back();
			P vec = lastvec;
			if(hitHL(beg, vec, pp, vv)){
				conv.push_back(getCP(beg,beg+vec, pp,pp+vv));
				// DEBUG(real(conv.back()));
				// DEBUG(imag(conv.back()));
				lastvec = vv;
				break;
			}else{
				assert(conv.size() >= 2);
				lastvec = conv.back() - conv[conv.size()-2];
				conv.pop_back();
				// DEBUG(conv.size());
			}
		}
	}
	// for(P p : conv){
	// 	DEBUG(real(p)); DEBUG(imag(p));
	// }
	// querying
	for(int idx : acc){
		if(v[idx] >= lastvec.real()-EPS){
			ans[idx] = -1;
			continue;
		}
		P pp = P(x[idx], 0);
		P vv = P(v[idx], 1);
		// DEBUG(x[idx]); DEBUG(v[idx]);
		// DEBUG(real(lastvec)); DEBUG(imag(lastvec));
		// ans[idx] = 1e200;
		if(abs(cross(lastvec, vv)) < EPS){
			ans[idx] = 1e200;
		}else{
			P cp = getCP(conv.back(), conv.back()+lastvec, pp, pp+vv);
			if(imag(cp) > EPS){
				ans[idx] = imag(cp);
			}else{
				ans[idx] = 1e200;
			}
		}
		// DEBUG(idx);
		// DEBUG(imag(cp));

		int low = 0, high = (int)conv.size()-2;
		while(low<=high){
			bool ko = low == high;
			int ppp = (low+high)/2;
			if(real(conv[ppp+1]-conv[ppp])/imag(conv[ppp+1]-conv[ppp]) <= v[idx]+EPS){
				// parallel
				low = ppp+1;
			}else{
				P cp = getCP(conv[ppp], conv[ppp+1], pp, pp+vv);
				int ck = hitHL2(conv[ppp], conv[ppp+1], pp, vv);
				if(imag(cp)>EPS && ck==0){
					P cp = getCP(conv[ppp],conv[ppp+1],pp,pp+vv);
					// DEBUG(imag(cp));
					ans[idx] = min(ans[idx], imag(cp));
					break;
				}else if(ck==1 || imag(cp)<=EPS){
					low = ppp+1;
				}else{
					high = ppp-1;
				}
			}
			if(ko)break;
		}
		if(ans[idx] == 1e200){
			ans[idx] = -1;
		}
	}
}

int main(){
	scanf("%d%lld%lld",&n,&xz,&vz);
	REP(i,n)scanf("%lld%lld",x+i,v+i);
	// zero
	REP(i,n)if(x[i]==xz)ans[i] = 0;
	// left convex, right access
	{
		vector<int> cvx, acc;
		REP(i,n){
			(x[i] <= xz ? cvx : acc).push_back(i);
		}
		solve(cvx, acc);
	}
	// reverse
	REP(i,n)x[i] = -x[i];
	REP(i,n)v[i] = -v[i];
	xz = -xz; vz = -vz;
	// REP(i,n){
	// 	printf("%.10f\n",ans[i]);
	// }
	// puts("");
	// left convex, right access
	{
		vector<int> cvx, acc;
		REP(i,n){
			(x[i] <= xz ? cvx : acc).push_back(i);
		}
		solve(cvx, acc);
	}
	// output
	REP(i,n){
		printf("%.15Lf\n",ans[i]);
	}
	return 0;
}
accuracy: 0.3548387096774194
time_ms: 630
memory_kb: 17688
final_rank: 16