Submission #941672

#TimeUsernameProblemLanguageResultExecution timeMemory
941672tnknguyen_Balloons (CEOI11_bal)C++14
100 / 100
613 ms13660 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define pdd pair<long double, long double> const int sz = 1e6 + 5; pdd 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(pdd ball, long double p){ long double l = 0, r = 1e9; long double x, y; tie(x, y) = ball; 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; stack<int> st; for(int i=1;i<=n;++i){ cin >> a[i].first >> a[i].second; while(st.size()){ a[i].second = min(a[i].second, bs(a[st.top()], a[i].first)); if(a[i].second >= a[st.top()].second){ st.pop(); } else{ break; } } st.push(i); cout<< fixed << setprecision(3) << a[i].second<<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...