Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#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);
    rep(i,0,n) cin >> p[i] >> h[i];

    auto ok=[&](long double vx,long double vy){
        bool res=true;
        rep(i,0,n){
            int l=p[i]/(2*vx*vy);
            long double t=(long double)p[i]/vx-2*vy*l;
            if((long double)-t*t/2+vy*t>=h[i]) continue;
            res=false;
            break;
        }
        return res;
    };

    long double pi=3.14159265359,ans=infll;
    rep(i,0,b+1){
        long double lb=pi/4,ub=pi/2;
        rep(j,0,64){
            long double m=(lb+ub)/2;
            long double v=sqrtl(d/sinl(2*m)/(i+1));
            long double vx=v*cosl(m),vy=v*sinl(m);
            if(ok(vx,vy)){
                ub=m;
                ans=min(ans,v);
            }else lb=m;
        }
    }
    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;
}