Submission #435300

# Submission time Handle Problem Language Result Execution time Memory
435300 2021-06-23T07:19:20 Z harshith828 Balloons (CEOI11_bal) C++14
100 / 100
200 ms 6908 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<long double> v;
    for(int i = 0;i < n;i++){
        cin >> x >> r;
        long double radius = r;
        //cout << x << " " << r << "\n";
        while(!s.empty()  ){
           // cout << radius << " ";
            radius = get_min((((pow((s.top()).first - x,2)))/(4.000*(s.top()).second)),radius);
            //cout << (((pow((s.top()).first - x,2)))/(4.000*(s.top()).second)) << " " << r << " " << s.top().second << "\n";
            radius = get_min(radius,r);
            if(radius > s.top().second){
                s.pop();
            }
            else{
                break;
            }
        }
       // cout <<"\n"; 
        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 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 21 ms 976 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 58 ms 1892 KB 50000 numbers
2 Correct 55 ms 1860 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 108 ms 3224 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 3588 KB 115362 numbers
2 Correct 109 ms 4232 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 182 ms 4660 KB 154271 numbers
2 Correct 184 ms 6904 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 200 ms 5660 KB 200000 numbers
2 Correct 180 ms 6908 KB 199945 numbers