Problem: Example

Input

100 1 0
50 100


Output

14.57738

Solution (in CPP):

Solution:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
const double INF = 1e18;
const double EPS = 1e-10;
 
int main(){
    double d;
    int n,b;
    cin >> d >> n >> b;
    vector<double> p(n),h(n);
    for(int i=0; i<n; i++){
        cin >> p[i] >> h[i];
    }
 
    double ans = INF;
    for(int i=0; i<=b; i++){
        double v = d/(i+1)/2; //V = vx*vy
        double vy = sqrt(v);
        for(int j=0; j<=i; j++){
            double center = j*2*v +v;
            for(int k=0; k<n; k++){
                double w = abs(p[k] -center);
                if(abs(w-v) < EPS){
                    vy = INF;
                    j = i+1;
                    break;
                }
                if(w -center > v) continue;
                vy = max(vy, sqrt(2*h[k]/(1-(w*w)/(v*v))));
            }
        }
        double vx = v/vy;
        ans = min(ans, sqrt(vx*vx +vy*vy));
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}