Submission #485604

# Submission time Handle Problem Language Result Execution time Memory
485604 2021-11-08T14:36:23 Z HaYoungJoon Balloons (CEOI11_bal) C++14
100 / 100
166 ms 11724 KB
#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 time Memory Grader output
1 Correct 0 ms 332 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1300 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 58 ms 3316 KB 50000 numbers
2 Correct 41 ms 3204 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 89 ms 5952 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 113 ms 6912 KB 115362 numbers
2 Correct 94 ms 7180 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 135 ms 8888 KB 154271 numbers
2 Correct 157 ms 11616 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 166 ms 10948 KB 200000 numbers
2 Correct 156 ms 11724 KB 199945 numbers