제출 #788309

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

long double calc(pair<long double, long double> p, long 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<long double> res(n);
    stack<pair<long double, long double>> st;
    for(int i=0; i<n; i++) {
        long double x, r;
        cin >> x >> r;
        long double max_r = r;
        while(!st.empty()) {
            pair<long double, long double> last = st.top();
            long double last_r = calc(last, x);

            max_r = min(max_r, last_r);

            if(max_r >= last.second) {
                st.pop();
                continue;
            } else break;
        }
        
        cout << fixed << setprecision(3) << max_r << '\n';
        st.push({x, r});
    }

    
}
#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...