제출 #1324354

#제출 시각아이디문제언어결과실행 시간메모리
1324354sh_qaxxorov_571Balloons (CEOI11_bal)C++20
100 / 100
113 ms1852 KiB
#include <iostream>
#include <vector>
#include <stack>
#include <iomanip>
#include <cmath>

using namespace std;

struct Balloon {
    double x, r;
};

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

    int n;
    cin >> n;

    stack<Balloon> s;

    for (int i = 0; i < n; i++) {
        double x, r_limit;
        cin >> x >> r_limit;

        double current_r = r_limit;

        while (!s.empty()) {
            // Ikki shar o'rtasidagi tegish radiusini hisoblash
            double r_touch = pow(x - s.top().x, 2) / (4.0 * s.top().r);

            // Radius eng kichik cheklovga teng bo'ladi
            current_r = min(current_r, r_touch);

            // Agar yangi shar eski shardan kattaroq bo'lsa,
            // eski shar endi boshqalarga tegmaydi (yangi shar to'sib qoladi)
            if (current_r >= s.top().r) {
                s.pop();
            } else {
                break;
            }
        }

        // Yangi sharni stekka qo'shish
        s.push({x, current_r});

        // Natijani chiqarish
        cout << fixed << setprecision(3) << current_r << "\n";
    }

    return 0;
}
#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...