Submission #443128

# Submission time Handle Problem Language Result Execution time Memory
443128 2021-07-09T18:41:29 Z prvocislo Balloons (CEOI11_bal) C++17
100 / 100
247 ms 8132 KB
// aww geometria !! :)
#include <bits/stdc++.h>
typedef long double ld;
using namespace std;

ld maxr(ld x1, ld r1, ld x2)
{
    ld x = r1, z = x2 - x1;
    return (z * z) / (4. * x);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout << fixed << setprecision(3);
    int n;
    cin >> n;
    vector<ld> x(n), r(n);
    vector<int> st;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> r[i];
        while (!st.empty())
        {
            r[i] = min(r[i], maxr(x[st.back()], r[st.back()], x[i]));
            if (r[i] > r[st.back()] - 1e-10) st.pop_back();
            else break;
        }
        st.push_back(i);
    }
    for (int i = 0; i < n; i++) cout << r[i] << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 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 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1012 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 65 ms 2384 KB 50000 numbers
2 Correct 62 ms 2148 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 127 ms 4288 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 188 ms 4936 KB 115362 numbers
2 Correct 142 ms 4808 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 205 ms 6508 KB 154271 numbers
2 Correct 240 ms 7748 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 247 ms 8132 KB 200000 numbers
2 Correct 243 ms 7784 KB 199945 numbers