제출 #788308

#제출 시각아이디문제언어결과실행 시간메모리
788308math_piBalloons (CEOI11_bal)C++14
10 / 100
167 ms6048 KiB
#include<bits/stdc++.h>
using namespace std;

double calc(pair<double, double> p, double x) {
    return (p.first - x) * (p.first - x) / (4 * p.second);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


    int n;
    cin >> n;

    vector<double> res(n);
    stack<pair<double, double>> st;
    for(int i=0; i<n; i++) {
        double x, r;
        cin >> x >> r;
        double max_r = r;
        while(!st.empty()) {
            pair<double, double> last = st.top();
            double last_r = calc(last, x);

            max_r = min(max_r, last_r);

            if(max_r >= last.second) {
                st.pop();
                continue;
            } else break;
        }
        
        res[i] = max_r;
        st.push({x, r});
    }

    cout << fixed << setprecision(3);

    for(auto &x: res) 
        cout << x << '\n';
}
#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...