Submission #868158

# Submission time Handle Problem Language Result Execution time Memory
868158 2023-10-30T14:20:26 Z Cookie Balloons (CEOI11_bal) C++14
40 / 100
2000 ms 8160 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("HCN.INP");
ofstream fout("HCN.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
//using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 9;
const int mxn = 1e5 + 5, mxq = 2e5 + 5, sq = 200, mxv = 2e6 + 5;
const ll inf = 1e17 + 5;
//const int base= (1 << 18);
int n;
ll x[mxn + 1], r[mxn + 1];
ld ans[mxn + 1];
ld dist(ld a, ld b, ld c, ld d){
    return(sqrtl((c - a) * (c - a) + (d - b) * (d - b)));
}
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> r[i];
    }
    ans[1] = r[1];
    cout << fixed << setprecision(10);
    cout << ans[1] << "\n";
    for(int i = 2; i <= n; i++){
        ld lp = 0.001, rp = r[i]; ans[i] = 0;
        for(int j = 0; j < 50; j++){
            ld mid = (lp + rp) / 2.0;
            bool ok = 1;
            for(int k = i - 1; k >= 1; k--){
                ld need = dist(x[k], ans[k], x[i], mid);
               
                if(need < mid + ans[k]){
                    ok = 0; break;
                }
            }
            if(ok){
                
                ans[i] = mid; lp = mid;
            }else{
                rp = mid;
            }
        }
        cout << ans[i] << "\n";
    }
    return(0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 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 14 ms 2396 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 219 ms 2392 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 3048 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2084 ms 3796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2060 ms 5236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 8028 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 8160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 8024 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -