제출 #1222799

#제출 시각아이디문제언어결과실행 시간메모리
1222799iamhereforfunBalloons (CEOI11_bal)C++20
30 / 100
115 ms8308 KiB
// IamHereForFun //

#include <bits/stdc++.h>

using namespace std;

#define LSOne(X) ((X) & -(X))

const int N = 2e5 + 5;
const int M = 15;
const int C = 26;
const int LG = 20;
const int R = 25e3 + 5;
const int B = 100;
const int O = 3e5 + 5;
const int INF = 1e9 + 5;
const int MOD = 998244353;
const int nx[] = {0, 1, 0, -1}, ny[] = {1, 0, -1, 0};

int n;
long double rad[N], d[N];
vector<pair<long double, int>> stk; // max x, id

void solve()
{
    cin >> n;
    for (int x = 0; x < n; x++)
    {
        long double c, r;
        cin >> c >> r;
        d[x] = c;
        while (!stk.empty())
        {
            if (stk.back().first < c)
            {
                stk.pop_back();
            }
            else
                break;
        }
        if (stk.empty())
        {
            rad[x] = r;
            stk.push_back({2e9, x});
        }
        else
        {
            int id = stk.back().second;
            rad[x] = min((long double)r, (c - d[id]) * (c - d[id]) / 4 / rad[id]);
            while (!stk.empty())
            {
                if (rad[stk.back().second] <= rad[x])
                {
                    stk.pop_back();
                }
                else
                    break;
            }
            if (stk.empty())
            {
                stk.push_back({2e9, x});
            }
            else
            {
                int id = stk.back().second;
                stk.push_back({sqrt(rad[x]) * (c - d[id]) / (sqrt(rad[id]) - sqrt(rad[x])) + c, x});
            }
        }
    }
    for (int x = 0; x < n; x++)
    {
        cout << fixed << setprecision(3) << rad[x] << "\n";
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    for (int x = 1; x <= t; x++)
    {
        solve();
    }
    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...