Submission #868158

#TimeUsernameProblemLanguageResultExecution timeMemory
868158CookieBalloons (CEOI11_bal)C++14
40 / 100
2084 ms8160 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...