# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647704 | Iliya | Balloons (CEOI11_bal) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
double radius(pair<double, double> a, double x){
return (a.first - x) * (a.first - x) / (4 * a.second);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
vector<double> ans(n);
stack<pair<double, double>> st;
for(int i = 0; i < n; i++){
double x, r;
cin >> x >> r;
while(!st.empty()){
double tmp = radius(st.top(), x);
r = min(r, tmp);
if(r >= tmp.second) st.pop();
else break;
}
ans[i] = r;
st.push({x, r});
}
cout << fixed << setprecision(5);
for(auto i : ans)
cout << i << '\n';
return 0;
}