#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 3, mod = 1e9 + 7, inf = 1e9 + 5;
double dist(double x1, double y1, double x2, double y2)
{
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
double gimr(double x1, double y1, double x2, double y2)
{
double l = 0, r = y2, mid, ans = 0;
while ((r - l) > 1e-9)
{
mid = (l + r) / 2;
if (dist(x1, y1, x2, mid) >= y1 + mid)
ans = max(ans, mid), l = mid;
else
r = mid;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
int n;
cin >> n;
stack<pair<double, double>> st;
for (int i = 0; i < n; i++)
{
double x, r;
cin >> x >> r;
while (true)
{
if (st.size())
r = min(r, gimr(st.top().first, st.top().second, x, r));
else
break;
if (r > st.top().second)
st.pop();
else
break;
}
cout << fixed << setprecision(3) << r << "\n";
st.push({x, r});
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2056 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
348 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
1024 KB |
50000 numbers |
2 |
Execution timed out |
2047 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
155 ms |
1364 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
1616 KB |
115362 numbers |
2 |
Execution timed out |
2035 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
233 ms |
1896 KB |
154271 numbers |
2 |
Execution timed out |
2041 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
290 ms |
1984 KB |
200000 numbers |
2 |
Execution timed out |
2048 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |