#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;
#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())
const ld INF = 1e18;
const ld eps = 1e-9;
const int mn = 2e5 + 5;
ll x[mn], maxR[mn];
ld rad[mn];
bool ok (int j, int i, ld tryR) {
ld tmp = (x[i] - x[j]) * (x[i] - x[j]);
return tmp - 4 * rad[j] * tryR >= -eps;
}
ld calc (int j, int i, ld L = 0, ld R = INF) {
if (abs(L - R) < eps) return L;
ld mid = (L + R) / 2;
if (ok(j, i, mid + eps)) return calc(j, i, mid + eps, R);
return calc(j, i, L, mid);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
for (int i = 1; i <= n; i++)
cin >> x[i] >> maxR[i];
rad[1] = maxR[1];
cout << fixed << setprecision(9) << rad[1] << "\n";
vector<int> vec = {1};
for (int i = 2; i <= n; i++) {
rad[i] = INF;
for (int j = vec.size() - 1; j >= 0; j--) {
ld cur = calc(vec[j], i, 0, maxR[i]);
if (cur < rad[i] + eps) rad[i] = cur;
else break;
}
while (vec.size() && rad[vec.back()] < rad[i]) vec.pop_back();
vec.push_back(i);
cout << rad[i] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
340th numbers differ - expected: '18.7500000000', found: '33.3333333870', error = '14.5833333870' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2396 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
251 ms |
3276 KB |
8083rd numbers differ - expected: '99.7190000000', found: '105.1249999930', error = '5.4059999930' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2044 ms |
2388 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2047 ms |
7220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2063 ms |
6332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2055 ms |
7508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2037 ms |
8272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |