Submission #941662

#TimeUsernameProblemLanguageResultExecution timeMemory
941662tnknguyen_Balloons (CEOI11_bal)C++14
30 / 100
2063 ms2820 KiB
#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 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...