Submission #683589

# Submission time Handle Problem Language Result Execution time Memory
683589 2023-01-18T19:14:14 Z NONTAC Balloons (CEOI11_bal) C++11
100 / 100
281 ms 8104 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<long double, long double> ll;
const int MAX_N = 200000;

int n;
long double x[MAX_N + 1], r[MAX_N + 1];
long double r_al[MAX_N + 1];
stack<ll> s;

long double expected_val(long double x1, long double r1, long double x2)
{
    return (x1 - x2) * (x1 - x2) / (4.0 * r1);
}

int main()
{
    //freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);

    cin>>n;

    for(int i = 0; i < n; i++){
        cin>>x[i]>>r[i];
    }

    for(int i = 0; i < n; i++){
        long double tmp = r[i];
        while(!s.empty() && s.top().second <= tmp){
            tmp = min(tmp, expected_val(s.top().first, s.top().second, x[i]));
            if(s.top().second <= tmp) s.pop();
        }

        if(!s.empty()) tmp = min(tmp, expected_val(s.top().first, s.top().second, x[i]));
        s.push(ll(x[i], tmp));
        printf("%.3Lf\n", tmp);
    }


    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1100 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 80 ms 2604 KB 50000 numbers
2 Correct 79 ms 2228 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 142 ms 4556 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 161 ms 5244 KB 115362 numbers
2 Correct 173 ms 4744 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 209 ms 6616 KB 154271 numbers
2 Correct 281 ms 7780 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 254 ms 8104 KB 200000 numbers
2 Correct 274 ms 7756 KB 199945 numbers