Submission #941467

# Submission time Handle Problem Language Result Execution time Memory
941467 2024-03-09T01:41:08 Z dwuy Balloons (CEOI11_bal) C++14
20 / 100
599 ms 8272 KB
#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) int32_t(s.length())
#define MASK(k)(1LL<<(k))
#define TASK "test"
#define int long long

using namespace std;

typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;

const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 200005;

int n;
pdd a[MX];
pdd v[MX];

void nhap(){
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i].fi >> a[i].se;
}

double sqr(double x){
    return x*x;
}

double euler(pdd a, pdd b){
    return sqrt(sqr(a.fi - b.fi) + sqr(a.se - b.se));
}

double dis(pdd ball, double p){
    double lo=0, hi=INF;
    for(int t=0; t<50; t++){
        double mid = (lo+hi)/2;
        if(euler(ball, {p, mid}) >= mid + ball.se) lo = mid;
        else hi = mid;
    }
    return (lo + hi)/2;
}

void solve(){   
    int id = 0;
    for(int i=1; i<=n; i++){
        while(id>1){
            double dis1 = dis(v[id], a[i].fi);
            double dis2 = dis(v[id - 1], a[i].fi);
            if(dis1 > dis2) id--;
            else break;
        }
        v[id+1] = {a[i].fi, min(a[i].se, id==0? 1e10 : dis(v[id], a[i].fi))};
        id++;
        cout << fixed << setprecision(3) << v[id].se << '\n';
    }
}

int32_t main(){
    fastIO;
    //file(TASK);

    nhap();
    solve();

    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 2392 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2392 KB 17th numbers differ - expected: '213.0000000000', found: '234.0000000000', error = '21.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2392 KB 504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 4872 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 166 ms 5076 KB 14174th numbers differ - expected: '0.7720000000', found: '1.3710000000', error = '0.5990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 298 ms 5844 KB 7447th numbers differ - expected: '0.9750000000', found: '8.0000000000', error = '7.0250000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 332 ms 6332 KB 4793rd numbers differ - expected: '0.9540000000', found: '10.6220000000', error = '9.6680000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 435 ms 7256 KB 1734th numbers differ - expected: '1856.0220000000', found: '1865.0000000000', error = '8.9780000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 599 ms 8272 KB 2735th numbers differ - expected: '1883.4630000000', found: '1899.0000000000', error = '15.5370000000'
2 Halted 0 ms 0 KB -