#include <bits/stdc++.h>
using namespace std;
double dist(const double &x1, const double &y1, const double &x2)
{
double dx = (x2 - x1);
return dx * dx / (4 * y1);
}
void solve()
{
struct elem
{
double x, r;
};
int n;
cin >> n;
vector<elem> a(n);
for (int i = 0; i < n; i++)
cin >> a[i].x >> a[i].r;
vector<double> radii(n);
stack<int> st;
for (int i = 0; i < n; i++)
{
double sz = a[i].r;
while (!st.empty())
{
int u = st.top();
sz = min(sz, dist(a[u].x, radii[u], a[i].x));
if (sz >= radii[u])
st.pop();
else
break;
}
st.emplace(i);
radii[i] = sz;
}
cout << fixed << setprecision(3);
for (int i = 0; i < n; i++)
cout << radii[i] << '\n';
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(NULL);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
852 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
1916 KB |
50000 numbers |
2 |
Correct |
60 ms |
2740 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
127 ms |
3540 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
155 ms |
4032 KB |
115362 numbers |
2 |
Correct |
145 ms |
6152 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
195 ms |
5296 KB |
154271 numbers |
2 |
Correct |
235 ms |
10088 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
242 ms |
6596 KB |
200000 numbers |
2 |
Correct |
234 ms |
10076 KB |
199945 numbers |