Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long double ldouble;
ldouble calc(ldouble r,ldouble w){
  return sqrt(r*r+(w/(2*r))*(w/(2*r)));
}
signed main(){
  int d,n,b;
  cin>>d>>n>>b;
  int p[n];
  ldouble h[n];
  for(int i=0;i<n;i++) cin>>p[i]>>h[i];
  ldouble INF=1e10;
  ldouble ans=INF;
  for(int i=1;i<=b+1;i++){
    ldouble w=(double)d/i;
    ldouble l=0,r=INF;
    for(int k=0;k<2000;k++){
      ldouble x=(l+r)/2;
      ldouble y=w/(2*x);
      //cout<<x<<" "<<y<<endl;
      bool f=1;
      for(int j=0;j<n;j++){
	ldouble ax=p[j];
	while(ax>=w) ax-=w;
	ldouble ay=(-1.0/(2*x*x)*(ax*ax))+((y/x)*ax);
	f&=(h[j]<=ay);
      }
      if(f) l=x;
      else r=x;
    }
    //cout<<i<<":"<<w<<" "<<r<<endl;
    ans=min(ans,calc(r,w));
    ldouble x=sqrt(w/2);
    if(x<=r) ans=min(ans,calc(x,w));
    /*
    l=0;
    for(int k=0;k<20;k++){
      ldouble m1=l+(r-l)/3;
      ldouble m2=l+(r-l)/3*2;
      ldouble t1=calc(m1,w);
      ldouble t2=calc(m2,w);
      ans=min(ans,t1);
      ans=min(ans,t2);
      //cout<<m1<<":"<<t1<<endl;
      //cout<<m2<<":"<<t2<<endl;
      if(t1<t2) r=m2;
      else l=m1;
    }
    */
  }
  printf("%.12Lf\n",ans);
  return 0;
}