제출 #1285597

#제출 시각아이디문제언어결과실행 시간메모리
1285597sritthebossBalloons (CEOI11_bal)C++20
10 / 100
319 ms14384 KiB
#include "bits/stdc++.h"
using namespace std;


struct Balloon {
    long double r;
    long double x;
    int idx;
};

int main() {
    int n;
    cin >> n;
    vector<Balloon> balloons(n);

    for (int i = 0; i < n; i++) {
        cin >> balloons[i].x;
        cin >> balloons[i].r;
        balloons[i].idx = i;
    }

    stack<Balloon> s;

    s.push(balloons[0]);
    vector<long double> final_r(n);

    for (int i = 1; i < n; i++) {

        while (!s.empty()) {
            long double new_r = (balloons[i].x - s.top().x) * (balloons[i].x - s.top().x) / (4.0 * s.top().r);
            new_r = min(balloons[i].r, new_r);

            if (new_r > s.top().r) {
                final_r[s.top().idx] = s.top().r;
                s.pop();
            } else {
                break;
            }
        }

        if (s.empty()) {
            s.push(balloons[i]);
        } else {
            long double new_r = (balloons[i].x - s.top().x) * (balloons[i].x - s.top().x) / (4.0 * s.top().r);
            s.push({min(new_r, balloons[i].r), balloons[i].x, balloons[i].idx});
        }
    }

    while (!s.empty()) {
        final_r[s.top().idx] = s.top().r;
        s.pop();
    }

    for (int i = 0; i < n; i++) {
        cout << fixed << setprecision(3) <<  final_r[i] << endl;
    }


}


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