Submission #850556

# Submission time Handle Problem Language Result Execution time Memory
850556 2023-09-16T22:11:42 Z orcslop Balloons (CEOI11_bal) C++17
100 / 100
502 ms 5460 KB
#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 time Memory Grader output
1 Correct 1 ms 604 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 48 ms 728 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 1652 KB 50000 numbers
2 Correct 125 ms 1612 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 251 ms 2680 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 291 ms 3156 KB 115362 numbers
2 Correct 302 ms 3296 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 384 ms 4144 KB 154271 numbers
2 Correct 502 ms 5344 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 491 ms 4712 KB 200000 numbers
2 Correct 489 ms 5460 KB 199945 numbers