Submission #941670

# Submission time Handle Problem Language Result Execution time Memory
941670 2024-03-09T09:27:40 Z tnknguyen_ Balloons (CEOI11_bal) C++14
70 / 100
311 ms 12376 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n' 
#define pdd pair<long double, long double>

const int sz = 1e5 + 5;
pdd a[sz];
long double f[sz];

long double dist(long double x, long double y, long double u, long double v){
    x = x - u;
    y = y - v;

    return sqrt(x*x + y*y);
}

long double bs(pdd ball, long double p){
    long double l = 0, r = 1e9;
    long double x, y;
    tie(x, y) = ball;

    for(int i=1;i<60;++i){
        long double mid = (l + r) / 2;
        if(dist(x, y, p, mid) >= mid + y){
            l = mid;
        }
        else{
            r = mid;
        }
    }

    return (l + r) / 2;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);

    int n;
    cin>>n;

    stack<int> st;
    for(int i=1;i<=n;++i){
        cin >> a[i].first >> a[i].second;    
        while(st.size()){
            a[i].second = min(a[i].second, bs(a[st.top()], a[i].first));
            if(a[i].second >= a[st.top()].second){
                st.pop();
            }
            else{
                break;
            }
        }
        st.push(i);
        cout<< fixed << setprecision(3) << a[i].second<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2396 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 61 ms 2840 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 148 ms 5716 KB 50000 numbers
2 Correct 155 ms 5660 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 306 ms 7128 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Runtime error 311 ms 12376 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 308 ms 12160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 307 ms 11872 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -