Submission #941662

# Submission time Handle Problem Language Result Execution time Memory
941662 2024-03-09T09:18:02 Z tnknguyen_ Balloons (CEOI11_bal) C++14
30 / 100
2000 ms 2820 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n' 
#define pll pair<long long, long long>

const int sz = 1e5 + 5;
pll 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(long double x, long double y, long double p){
    long double l = 0, r = 1e9;
    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;

    for(int i=1;i<=n;++i){
        cin >> a[i].first >> a[i].second;    
        f[i] = a[i].second;
        for(int j=i-1;j>=1;--j){
            f[i] = min(f[i], bs(a[j].first, f[j], a[i].first));
        }
        cout << fixed << setprecision(3) << f[i]<<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 140 ms 2396 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2054 ms 2804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2063 ms 2640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2053 ms 2648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2025 ms 2784 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2029 ms 2820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2001 ms 2760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2058 ms 2644 KB Time limit exceeded
2 Halted 0 ms 0 KB -