#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MAXN=2e5+5;
/*
store stack of the ballons that we might possibly hit,
with heights in decreasing order from the first
*/
double findR(pair<double, double> a, double b)
{
return ((a.first-b)*(a.first-b))/(4*a.second);
}
ll n;
double radii[MAXN];
stack<pair<double, double>> st;
int main()
{
cin >> n;
for (int i=0; i<n; i++)
{
double x, r;
cin >> x >> r;
double maxR=r;
while (!st.empty())
{
pair<double, double> cur=st.top();
double curR=findR(cur, x);
maxR=min(maxR, curR);
if (maxR>=cur.second)
{
st.pop();
continue;
}
break;
}
radii[i]=maxR;
st.push({x, maxR});
}
cout << fixed << setprecision(3);
for (int i=0; i<n; i++)
{
cout << radii[i] << "\n";
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |