제출 #1294116

#제출 시각아이디문제언어결과실행 시간메모리
1294116sritthebossBalloons (CEOI11_bal)C++20
100 / 100
239 ms7996 KiB
#include "bits/stdc++.h"
#define INF 1e18
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<pair<double, double>> balloons(n);

    for (int i = 0; i < n; i++) {
        cin >> balloons[i].first >> balloons[i].second;
    }

    stack<pair<double, double>> s;
    vector<double> ans(n);

    for (int i = 0; i < n; i++) {
        pair<double, double> b = balloons[i];
        if (s.empty()) {
            ans[i] = b.second;
            s.push(b);
        } else {
            double new_r = b.second;
            while (!s.empty()) {
                new_r = min(new_r, pow(s.top().first - b.first, 2) / (4 * s.top().second));
                if (new_r > s.top().second) {
                    s.pop();
                } else {
                    break;
                }
            }
            s.push({b.first, new_r});
            ans[i] = new_r;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << fixed << setprecision(3) << ans[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...