Submission #485604

#TimeUsernameProblemLanguageResultExecution timeMemory
485604HaYoungJoonBalloons (CEOI11_bal)C++14
100 / 100
166 ms11724 KiB
#include <bits/stdc++.h>

using namespace std;

long double X[200001],R[200001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("BongBong.INP","r",stdin);
    //freopen("BongBong.OUT","w",stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> X[i] >> R[i];
    printf("%.3Lf\n",R[1]);
    stack<pair<long double, long double> > st;
    st.push({X[1],R[1]});
    for (int i = 2; i <= n; i++) {
        while (!st.empty()) {
            long double x = st.top().first, r = st.top().second;
            R[i] = min(R[i],(X[i] - x)*(X[i]-x)/(4*r));
            if (R[i] >= r) st.pop();
            else break;
        }
        st.push({X[i],R[i]});
        printf("%.3Lf\n",R[i]);
    }
    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...