제출 #929150

#제출 시각아이디문제언어결과실행 시간메모리
929150AanjaneyBalloons (CEOI11_bal)C++17
0 / 100
115 ms11316 KiB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
bool no_conflict(double ri, double rj, ll xi, ll xj)
{
    double lhs = 4 * ri * rj;
    double rhs = (xi - xj) * (xi - xj);
    return lhs > rhs;
}
double calc_r(ll xi, ll xj, double rj)
{
    double numerator = (xi - xj) * (xi - xj);
    double denominator = 4 * rj;
    return numerator / double(denominator);
}
void solve(ll tc)
{
    ll n;
    cin >> n;
    vector<ll> x(n), r(n);
    vector<double> res(n);
    for (ll i = 0; i < n; ++i)
    {
        cin >> x[i] >> r[i];
    }
    stack<pair<ll, double>> s;
    for (ll i = 0; i < n; ++i)
    {
        if (s.empty())
            res[i] = double(r[i]);
        else
        {
            while (!s.empty() && double(r[i]) > s.top().second && no_conflict(r[i], s.top().second, x[i], s.top().first))
                s.pop();
            if (!s.empty())
                res[i] = min(double(r[i]), calc_r(x[i], s.top().first, s.top().second));
            else
                res[i] = double(r[i]);
        }
        s.push({x[i], r[i]});
    }
    for (ll i = 0; i < n; ++i)
        cout << fixed << setprecision(3) << res[i] << "\n";
}
int main()
{
    speed;
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++)
        solve(i);
}
#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...