Submission #435261

#TimeUsernameProblemLanguageResultExecution timeMemory
435261harshith828Balloons (CEOI11_bal)C++14
10 / 100
345 ms3524 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(){
    
    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;
        while(!s.empty()  and get_min((((double)(pow((s.top()).first - x,2)))/(4.000*(s.top()).second)),r) >= s.top().second){
            s.pop();
        }
        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++){
        cout << fixed << setprecision(3);
        if(i != n - 1){
            cout << v[i] << "\n";
        }
        else{
            cout << 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...