Submission #850556

#TimeUsernameProblemLanguageResultExecution timeMemory
850556orcslopBalloons (CEOI11_bal)C++17
100 / 100
502 ms5460 KiB
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size() 

double maxr(double x, double r2){
    return x * x / (4 * r2); 
}

int main() { 
    int n; 
    cin >> n; 
    stack<pair<double, double>> stk; 
    for(int i = 0; i < n; i++){
        double x, rad, keep; 
        cin >> x >> rad; 
        keep = rad; 
        while(!stk.empty()){
            pair<double, double> curr = stk.top(); 
            double new_r = maxr(x - curr.first, curr.second); 
            keep = min(keep, new_r); 
            if(curr.second <= keep) {
                stk.pop(); 
                continue; 
            }
            else break; 
        }
        cout << fixed << setprecision(3) << keep << '\n'; 
        stk.push(make_pair(x, keep)); 
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...