제출 #1344549

#제출 시각아이디문제언어결과실행 시간메모리
1344549jingca2012Balloons (CEOI11_bal)C++20
100 / 100
126 ms6572 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    size_t N; cin >> N;
    vector<double> x(N);
    vector<double> r(N);
    for (size_t i=0; i<N; ++i){
        cin >> x[i] >> r[i];
    }
    stack<pair<double, size_t>> balloons;
    // if curr doesn't touch 
    vector<double> ans(N);
    for (size_t i=0; i<N; ++i){
        double maxR = r[i];
        while (!balloons.empty()){
            auto& [rj, j] = balloons.top();
            double R = (x[i]-x[j])*(x[i]-x[j]) / (4.0 * rj);
            maxR = min(maxR, R);
            if (maxR >= rj) {
                balloons.pop();
            } else {
                // maxR < rj
                break;
            }
        }
        balloons.push({maxR, i});
        ans[i] = maxR;
    }
    cout << fixed << setprecision(3);
    for (const auto& r: ans)
        cout << r << "\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...