Submission #435286

#TimeUsernameProblemLanguageResultExecution timeMemory
435286harshith828Balloons (CEOI11_bal)C++14
20 / 100
185 ms6812 KiB
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;

long double get_min(long double x1,long double x2){
    if(x1 > x2){
        return x2;
    }
    return x1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long int n;
    cin >> n;
    stack<pair<long long int,double>> s;
    long long int x,r;
    vector<double> v;
    for(int i = 0;i < n;i++){
        cin >> x >> r;
        double radius = r;
        while(!s.empty() and (s.top()).first + (s.top()).second >= x - r ){
            radius = get_min((((pow((s.top()).first - x,2)))/(4.000*(s.top()).second)),radius);
            radius = get_min(radius,r);
            if(radius > s.top().second){
                s.pop();
            }
            else{
                break;
            }
        }
        // }
        // if(!s.empty()){
        //     radius = (((double)(pow((s.top()).first - x,2)))/(4.000*(s.top()).second));
        // }
        // else{
        //     radius = r;
        // }
        // if(radius > r){
        //     radius = r;
        // }

        v.push_back(radius);
        s.push(make_pair(x,radius));
    }
    for(int i = 0;i < n;i++){
        if(i != n - 1){
            cout << fixed << setprecision(6) << v[i] << "\n";
        }
        else{
            cout << fixed << setprecision(6) << v[i];
        }
    }
    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...