Submission #435272

# Submission time Handle Problem Language Result Execution time Memory
435272 2021-06-23T06:46:27 Z harshith828 Balloons (CEOI11_bal) C++14
100 / 100
191 ms 9268 KB
#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()){
            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 time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 19 ms 768 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 49 ms 1468 KB 50000 numbers
2 Correct 41 ms 2520 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 97 ms 2360 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 117 ms 2700 KB 115362 numbers
2 Correct 101 ms 5592 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 152 ms 3464 KB 154271 numbers
2 Correct 163 ms 9268 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 191 ms 4192 KB 200000 numbers
2 Correct 160 ms 9184 KB 199945 numbers