Problem:
Problem D:
Space Golf
You surely have never heard of this new planet surface exploration scheme, as it is being carried out in a project with utmost secrecy. The scheme is expected to cut costs of conventional rovertype mobile explorers considerably, using projected-type equipment nicknamed "observation bullets".
Bullets do not have any active mobile abilities of their own, which is the main reason of their cost-efficiency. Each of the bullets, after being shot out on a launcher given its initial velocity, makes a parabolic trajectory until it touches down. It bounces on the surface and makes another parabolic trajectory. This will be repeated virtually infinitely.
We want each of the bullets to bounce precisely at the respective spot of interest on the planet surface, adjusting its initial velocity. A variety of sensors in the bullet can gather valuable data at this instant of bounce, and send them to the observation base. Although this may sound like a conventional target shooting practice, there are several issues that make the problem more difficult.
There may be some obstacles between the launcher and the target spot. The obstacles stand upright and are very thin that we can ignore their widths. Once the bullet touches any of the obstacles, we cannot be sure of its trajectory thereafter. So we have to plan launches to avoid these obstacles.
Launching the bullet almost vertically in a speed high enough, we can easily make it hit the target without touching any of the obstacles, but giving a high initial speed is energyconsuming. Energy is extremely precious in space exploration, and the initial speed of the bullet should be minimized. Making the bullet bounce a number of times may make the bullet reach the target with lower initial speed.
The bullet should bounce, however, no more than a given number of times. Although the body of the bullet is made strong enough, some of the sensors inside may not stand repetitive shocks. The allowed numbers of bounces vary on the type of the observation bullets.
You are summoned engineering assistance to this project to author a smart program that tells the minimum required initial speed of the bullet to accomplish the mission.
Figure D.1 gives a sketch of a situation, roughly corresponding to the situation of the Sample
Input 4 given below.
Figure D.1. A sample situation
You can assume the following.
The atmosphere of the planet is so thin that atmospheric resistance can be ignored.
The planet is large enough so that its surface can be approximated to be a completely flat plane.
The gravity acceleration can be approximated to be constant up to the highest points a bullet can reach.
These mean that the bullets fly along a perfect parabolic trajectory.
You can also assume the following.
The surface of the planet and the bullets are made so hard that bounces can be approximated as elastic collisions. In other words, loss of kinetic energy on bounces can be ignored. As we can also ignore the atmospheric resist
...(truncated)

Submitted solutions:

code_snippet: #include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>b)return 0; a=b; return 1;}
#define bitUP(x,a) ((x>>a)&1)
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-6;
long double pi = acos(-1);

//要素数n 初期値x
template<typename T>
inline vector<T> vmake(size_t n,T x){
  return vector<T>(n,x);
}

//a,b,c,x data[a][b][c] 初期値x
template<typename... Args>
auto vmake(size_t n,Args... args){
    auto v=vmake(args...);
    return vector<decltype(v)>(n,move(v));
}



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    using DD=long double;
    int d,n,b;
    cin>>d>>n>>b;
    b++;
    int p[11],h[11];
    for(int i=0;i<n;i++){
        cin>>p[i]>>h[i];
    }
    DD ret=1e120;
    for(int num_bound=1;num_bound<=b;num_bound++){
        DD per_d=(double)d/num_bound;
        DD ok=1000000,ng=0; //ok=??
        int N=10000;
        while(N--){
            DD mid=(ok+ng)/2;
            DD time=2*mid/1.0L;
            DD vx=per_d/time;
            bool broken=false;
            for(int i=0;i<n;i++){
                DD d=fmod(p[i],per_d);
                DD y=-1*(1.0L/(2*vx*vx))*d*d+mid/vx*d;
                if(y<h[i]) broken=true;
            }
            if(not broken) ok=mid;
            else ng=mid;
        }
        /*double time=2*ok/1.0L;
        double vx=per_d/time;
        cerr<<vx<<" "<<ok<<endl;
        if(vx>ok) ok=sqrt(per_d/2),vx=ok;
        cerr<<num_bound<<" "<<sqrt(vx*vx+ok*ok)<<endl;*/
        ok=max(ok,sqrt(per_d/2));
        DD vx=per_d/(ok*2);
        chmin(ret,sqrt(vx*vx+ok*ok));
    }
    cout<<ret<<endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3632
final_rank: 7

code_snippet: #include<bits/stdc++.h>
#define double long double
#define N 10
using namespace std;
typedef pair<bool,double> P;

const double EPS = 1e-12;

double d, n, b, p[N], h[N];

P check(double s, double A, int cnt){
  
  double l = 0, r = 1000000000;
  
  while(l+EPS<r){
    
    double m = (l + r) / 2.0;
    double vx = m * cos(s);
    double vy = m * sin(s);
    double x = vx * 2 * vy;
    
    if(x<A) l=m;
    else r=m;

  }
  
  double vx = l * cos(s);
  double vy = l * sin(s);
  
  bool res = true;
  
  double x=0;
  
  for(int i=0;i<=cnt;i++){
    
    for(int j=0;j<n;j++)
      
      if(x-EPS<p[j]&&p[j]<x+A+EPS){
	
	if(abs(p[j]-x)<EPS||abs(p[j]-x)<EPS) res=false;
	
	double X=abs(p[j]-x);
	
	if(-X*X/(2*vx*vx)+X*vy/vx<=h[j]+EPS) res=false;
      }
    
    x+=A;
  }
  
  return P(res, l);
}

double sim(int cnt){
  
  double A=1.0*d/(cnt+1);
  
  double l = M_PI/4.0, r = M_PI/2.0;
  
  while(l+EPS<r){
    
    double m = (l + r) / 2.0;
    
    if(!check(m,A,cnt).first) l = m;
    else r=m;
  }
  
  return check(l,A,cnt).second;
}

int main(){
  
  cin>>d>>n>>b;

  for(int i=0;i<n;i++) cin>>p[i]>>h[i];
  
  double ans=(1e9);
  
  for(int i=0;i<=b;i++) ans=min(ans, sim(i));
  
  printf("%.8Lf\n", ans);
    
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3604
final_rank: 6

code_snippet: #include <bits/stdc++.h>
#define int long long
#define double long double
#define N 20
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
const double g = 1.0;
int p[N],h[N];

double calcX(double radian,double v){
  double vix = v * cos(radian);
  double viy = v * sin(radian);
  double t = 2 * viy / g;
  return vix * t;
}

double calcV(double x,int n,int b,double radian){
  double L = 0, R = 1e10, cnt = 100;
  while(cnt--){
    double M = (L+R)/2;
    if(calcX(radian,M) > x) R = M;
    else L = M;
  }
    
  double v = L,pos = 0;
  for(int i=0;i<b;i++, pos += x){
    for(int j=0;j<n;j++){
      if(!(pos <= p[j] && p[j] <= pos+x)) continue;
      double vix = v * cos(radian);
      double viy = v * sin(radian);
      double t = (p[j] - pos)/vix;
      double y = -(g*t/2 - viy) * t;
      if(y-h[j]+EPS < 0) return INF;
    }
  }
  return v;  
}

double solve(double x,int n,int b){
  double L = PI/4,R = PI/2,cnt = 100;
  while(cnt--){
    double M = (L+R)/2;
    if(calcV(x,n,b,M) < INF) R = M; 
    else L = M;
  }
  return calcV(x,n,b,R);
}

signed main(){
  int D,n,B;
  cin>>D>>n>>B;
  for(int i=0;i<n;i++) cin>>p[i]>>h[i];
  double ans = INF;
  for(int i=1;i<=B+1;i++) Min(ans,solve(1.0*D/i,n,i));
  printf("%.5Lf\n",ans);
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3512
final_rank: 4

code_snippet: #include <bits/stdc++.h>
#define int long long
#define double long double
#define N 20
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
const double g = 1.0;
int p[N],h[N];


double calcX(double radian,double v){
  double vix = v * cos(radian);
  double viy = v * sin(radian);
  double t = 2 * viy / g;
  return vix * t;
}

double calcV(double x,int n,int b,double radian){
  double L = 0, R = 1e10, cnt = 100;
  while(cnt--){
    double M = (L+R)/2;
    if(calcX(radian,M) > x) R = M;
    else L = M;
  }
    
  double v = L,pos = 0;
  for(int i=0;i<b;i++, pos += x){
    for(int j=0;j<n;j++){
      //if(pos == p[j] || p[j] == pos+x) return INF;
      if(!(pos <= p[j] && p[j] <= pos+x)) continue;
      double vix = v * cos(radian);
      double viy = v * sin(radian);
      double t = (p[j] - pos)/vix;
      double y = -(g*t/2 - viy) * t;
      if(y-h[j]+EPS < 0) return INF;
    }
  }
  return v;  
}

double solve(double x,int n,int b){

  double L = PI/4,R = PI/2,cnt = 100;
  while(cnt--){
    double M = (L+R)/2;
    if(calcV(x,n,b,M) < INF) R = M; 
    else L = M;
  }
  return calcV(x,n,b,R);
}


signed main(){
  int D,n,B;
  cin>>D>>n>>B;
  for(int i=0;i<n;i++) cin>>p[i]>>h[i];
  double ans = INF;
  for(int i=1;i<=B+1;i++) Min(ans,solve(1.0*D/i,n,i));
  printf("%.5Lf\n",ans);
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3512
final_rank: 5

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-5;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int d,n,b;
    cin >> d >> n >> b;
    vector<long double> p(n),h(n);
    long double h_max=0;
    rep(i,0,n){
        cin >> p[i] >> h[i];
        h_max=max(h_max,h[i]);
    }

    int loop_num=1e7*6;
    long double ans=infll;
    long double lb=sqrtl(2*h_max)-eps,ub=d*log10l(d);
    rep(i,0,loop_num+1){
        long double vy=lb+(long double)i/loop_num*(ub-lb);
        if(ans<=vy*vy) break;
        for(int j=b+1; j>=1; --j){
            long double vx=(long double)d/2/vy/j;
            if(ans<=vx*vx) break;
            long double tmp=vx*vx+vy*vy;
            if(ans<=tmp) continue;
            bool ok=true;
            rep(k,0,n){
                int l=p[k]/(2*vx*vy);
                long double t=(long double)p[k]/vx-2*vy*l;
                if((long double)-t*t/2+vy*t>=h[k]) continue;
                ok=false;
                break;
            }
            if(ok) ans=min(ans,tmp);
        }
    }
    cout << sqrtl(ans) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}
accuracy: 0.16666666666666666
time_ms: 660
memory_kb: 3424
final_rank: 9

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int d,n,b;
    cin >> d >> n >> b;
    vector<long double> p(n),h(n);
    long double h_max=0;
    rep(i,0,n){
        cin >> p[i] >> h[i];
        h_max=max(h_max,h[i]);
    }

    int loop_num=1e7*4;
    long double ans=infll;
    long double lb=sqrtl(2*h_max),ub=d*log10l(d);
    rep(i,0,loop_num+1){
        long double vy=lb+(long double)i/loop_num*(ub-lb);
        if(ans<=vy*vy) break;
        for(int j=b+1; j>=1; --j){
            long double vx=(long double)d/2/vy/j;
            if(ans<=vx*vx) break;
            long double tmp=vx*vx+vy*vy;
            if(ans<=tmp) continue;
            bool ok=true;
            rep(k,0,n){
                int l=p[k]/(2*vx*vy);
                long double t=(long double)p[k]/vx-2*vy*l;
                if((long double)-t*t/2+vy*t>=h[k]) continue;
                ok=false;
                break;
            }
            if(ok) ans=min(ans,tmp);
        }
    }
    cout << sqrtl(ans) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}
accuracy: 0.16666666666666666
time_ms: 440
memory_kb: 3424
final_rank: 8

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int d,n,b;
    cin >> d >> n >> b;
    vector<long double> p(n),h(n);
    long double h_max=0;
    rep(i,0,n){
        cin >> p[i] >> h[i];
        h_max=max(h_max,h[i]);
    }

    int loop_num=1e7*4;
    long double ans=infll;
    long double lb=sqrtl(2*h_max),ub=d*4;
    rep(i,0,loop_num+1){
        long double vy=lb+(long double)i/loop_num*(ub-lb);
        if(ans<=vy*vy) break;
        for(int j=b+1; j>=1; --j){
            long double vx=(long double)d/2/vy/j;
            if(ans<=vx*vx) break;
            long double tmp=vx*vx+vy*vy;
            if(ans<=tmp) continue;
            bool ok=true;
            rep(k,0,n){
                int l=p[k]/(2*vx*vy);
                long double t=(long double)p[k]/vx-2*vy*l;
                if((long double)-t*t/2+vy*t>=h[k]) continue;
                ok=false;
                break;
            }
            if(ok) ans=min(ans,tmp);
        }
    }
    cout << sqrtl(ans) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}
accuracy: 0.027777777777777776
time_ms: 240
memory_kb: 3268
final_rank: 11

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int d,n,b;
    cin >> d >> n >> b;
    vector<long double> p(n),h(n);
    long double h_max=0;
    rep(i,0,n){
        cin >> p[i] >> h[i];
        h_max=max(h_max,h[i]);
    }

    int loop_num=1e7;
    long double ans=infll;
    long double lb=sqrtl(2*h_max),ub=d;
    rep(i,0,loop_num+1){
        long double vy=lb+(long double)i/loop_num*(ub-lb);
        if(ans<=vy) break;
        for(int j=b+1; j>=1; --j){
            long double vx=(long double)d/2/vy/j;
            if(ans<=vx) break;
            long double tmp=sqrtl(vx*vx+vy*vy);
            if(ans<=tmp) continue;
            bool ok=true;
            rep(k,0,n){
                int l=p[k]/(2*vx*vy);
                long double t=(long double)p[k]/vx-2*vy*l;
                if((long double)-t*t/2+vy*t>=h[k]) continue;
                ok=false;
                break;
            }
            if(ok) ans=min(ans,tmp);
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}
accuracy: 0.05555555555555555
time_ms: 560
memory_kb: 3268
final_rank: 10

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int d,n,b;
    cin >> d >> n >> b;
    vector<long double> p(n),h(n);
    long double h_max=0;
    rep(i,0,n){
        cin >> p[i] >> h[i];
        h_max=max(h_max,h[i]);
    }

    int loop_num=1e7*2;
    long double ans=infll;
    rep(i,1,loop_num+1){
        long double vy=(long double)i/loop_num*2*d;
        if(ans<=vy) break;
        if(vy/2*vy<h_max) continue;
        for(int j=b+1; j>=1; --j){
            long double vx=(long double)d/2/vy/j;
            if(ans<=vx) break;
            long double tmp=sqrtl(vx*vx+vy*vy);
            if(ans<=tmp) continue;
            bool ok=true;
            rep(k,0,n){
                int l=p[k]/(2*vx*vy);
                long double t=(long double)p[k]/vx-2*vy*l;
                if((long double)-t*t/2+vy*t>=h[k]) continue;
                ok=false;
                break;
            }
            if(ok) ans=min(ans,tmp);
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}
accuracy: 0.027777777777777776
time_ms: 300
memory_kb: 3304
final_rank: 12

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int d,n,b;
    cin >> d >> n >> b;
    vector<long double> p(n),h(n);
    rep(i,0,n) cin >> p[i] >> h[i];

    int loop_num=1e7*3.5;
    long double ans=infll;
    rep(i,1,loop_num+1){
        long double vy=(long double)i/loop_num*10*d;
        if(ans<=vy) break;
        for(int j=b+1; j>=1; --j){
            long double vx=(long double)d/2/vy/j;
            if(ans<=vx) break;
            long double tmp=sqrtl(vx*vx+vy*vy);
            if(ans<=tmp) continue;
            bool ok=true;
            rep(k,0,n){
                int l=p[k]/(2*vx*vy);
                long double t=(long double)p[k]/vx-2*vy*l;
                if((long double)-t*t/2+vy*t>=h[k]) continue;
                ok=false;
                break;
            }
            if(ok) ans=min(ans,tmp);
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}
accuracy: 0.027777777777777776
time_ms: 650
memory_kb: 3284
final_rank: 13

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int d,n,b;
    cin >> d >> n >> b;
    vector<long double> p(n),h(n);
    rep(i,0,n) cin >> p[i] >> h[i];

    int loop_num=1e7*3;
    long double ans=infll;
    rep(i,1,loop_num+1){
        long double vy=(long double)i/loop_num*8*d;
        if(ans<=vy) break;
        for(int j=b+1; j>=1; --j){
            long double vx=(long double)d/2/vy/j;
            if(ans<=vx) break;
            long double tmp=sqrtl(vx*vx+vy*vy);
            if(ans<=tmp) continue;
            bool ok=true;
            rep(k,0,n){
                int l=p[k]/(2*vx*vy);
                long double t=(long double)p[k]/vx-2*vy*l;
                if((long double)-t*t/2+vy*t>=h[k]) continue;
                ok=false;
                break;
            }
            if(ok) ans=min(ans,tmp);
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}
accuracy: 0.027777777777777776
time_ms: 700
memory_kb: 3256
final_rank: 14

code_snippet: // Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

class range {
    struct Iterator {
        int val, inc;
        int operator*() {return val;}
        bool operator!=(Iterator& rhs) {return val < rhs.val;}
        void operator++() {val += inc;}
    };
    Iterator i, n;
    public:
    range(int e) : i({0, 1}), n({e, 1}) {}
    range(int b, int e) : i({b, 1}), n({e, 1}) {}
    range(int b, int e, int inc) : i({b, inc}), n({e, inc}) {}
    Iterator& begin() {return i;}
    Iterator& end() {return n;}
};

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int N, B;
    double D;
    while(cin >> D >> N >> B) {
        vector<double> P(N);
        vector<double> H(N);
        REP(i, N) cin >> P[i] >> H[i];

        double ans = 1e16;

        for(int b = 0; b <= B; b++) {
            double p = D / (b+1);
            double lb = M_PI / 4;
            double ub = M_PI / 2;
            double v = 0;
            REP(_, 60) {
                double th = (lb+ub) / 2;
                double vx = sqrt(p / 2.0 / tan(th));

                v = vx/cos(th); // update

                bool ok = true;
                REP(i, N) {
                    double x = P[i] - int(P[i] / p) * p;
                    double y = -(0.5/vx/vx)*x*x + tan(th)*x;
                    if(y < H[i]) ok = false;
                }
                if(ok) {
                    ub = th;
                } else {
                    lb = th;
                }
            }

            ans = min(ans, v);
        }
        cout << ans << endl;
    }

    return 0;
}

/* vim:set foldmethod=marker: */
accuracy: 1
time_ms: 40
memory_kb: 1404
final_rank: 3

code_snippet: #include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

typedef long double D;

struct Node {
  D p;
  D h;
};

const D EPS = 1e-10;

int sig(D a, D b) {
  if(a < b - EPS) return -1;
  if(a > b + EPS) return +1;
  return 0;
}

bool check(D th, D speed, D start, D end, const vector<Node> &objs) {
  D vx = speed * cos(th);
  D vy = speed * sin(th);
  bool ok = true;
  for(int i = 0; i < (int)objs.size(); ++i) {
    if(sig(start, objs[i].p) <= 0 && sig(objs[i].p, end) <= 0) {
      D x = objs[i].p - start;
      D y = -(x*x/(2*vx*vx)) + vy*x/vx;
      if(sig(y, objs[i].h) < 0) {
        ok = false;
      }
    }
  }
  return ok;
}

D speed(D th, D len) {
  return sqrt(len / (sin(2*th)));
}

void test(D th, D len, D pos) {
  D sp = speed(th, len);
  D vx = sp * cos(th);
  D vy = sp * sin(th);
  D y = -(pos*pos/(2*vx*vx)) + (vy/vx)*pos;
  DEBUG(y);
}

int main() {
  D distance;
  int N, B;
  cin >> distance >> N >> B;
  vector<Node> objs(N);
  for(int i = 0; i < N; ++i) {
    cin >> objs[i].p >> objs[i].h;
  }
  B++;
  D ans = 1e20;
  for(int b = 1; b <= B; ++b) {
    for(int i = 0; i < b; ++i) {
      D start = distance / b * i;
      D end = distance / b * (i + 1);
      D len = abs(end - start);
      D estm;
      // DEBUG(start);
      // DEBUG(end);
      // DEBUG(len);
      // DEBUG(speed(M_PI/4, len));
      // D vx = speed(M_PI/4, len)*cos(M_PI/4);
      // D vy = speed(M_PI/4, len)*sin(M_PI/4);
      // DEBUG(-(len*len/(2*vx*vx))+(vy/vx)*len);
        // DEBUG("false");
      D lb = M_PI/4, ub = M_PI/2;
      for(int t = 0; t < 300; ++t) {
        D mid = (lb + ub) / 2;
        if(check(mid, speed(mid, len), start, end, objs)) {
          ub = mid;
        }
        else {
          lb = mid;
        }
      }
      estm = ub;
      D estm_sp = speed(estm, len);
      bool ok = true;
      for(int j = 0; j < b; ++j) {
        D start2 = distance / b * j;
        D end2 = distance / b * (j + 1);
        if(check(estm, estm_sp, start2, end2, objs) == false) {
          ok = false;
        }
      }
      if(ok) {
        ans = min(ans, estm_sp);
      }
    }
  }
  cout.setf(ios::fixed); cout.precision(10);
  cout << ans << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 1308
final_rank: 2

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <ctime>
#include <list>
#include <complex>
#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const double EPS = 1e-9;

bool check(double x, double y, double vx, double vy){
	double yy = -1 / 2. / vx / vx*x*x + vy / vx*x;
	return y < yy + EPS;
}

int main(){
	int d, n, b;
	cin >> d >> n >> b;

	vector<int> p(n), h(n);
	rep(i, n) cin >> p[i] >> h[i];

	double ans = 1e100;
	FOR(i, 1, b + 2){
		double len = (double)d / i;

		double lb = 0, ub = sqrt(len / 2);
		rep(j, 10000){
			double mid = (lb + ub) / 2;
			bool ok = true;
			rep(k, n){
				double pp = p[k];
				while (pp > len - EPS) pp -= len;
				ok &= check(pp, h[k], mid, len / 2 / mid);
			}
			if (ok) lb = mid;
			else ub = mid;
		}
		if (lb < EPS) continue;
		double vx = lb, vy = len / 2 / vx;
		ans = min(ans, sqrt(vx*vx+vy*vy));
	}
	cout.setf(ios::fixed);
	cout.precision(10);
	cout << ans << endl;


	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1268
final_rank: 1