#include<bits/stdc++.h>
#define sanastd using namespace std
sanastd;
const int MAXN = 1000 * 1000 + 10;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;
int n, r[MAXN], x[MAXN];
long double ans[MAXN];
stack <int> balloon;
bool check(int ind1, int ind2, double mid)
{
long double d = (x[ind1] - x[ind2]) * (x[ind1] - x[ind2]) + (ans[ind2] - mid) * (ans[ind2] - mid);
if(sqrt(d) < mid + ans[ind2]) return 0;
else return 1;
}
int main ()
{
cout<<fixed<<setprecision(15);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> x[0] >> r[0];
balloon.push(0);
ans[0] = r[0];
cout << r[0] << endl;
for(int i = 1; i < n; i++){
cin >> x[i] >> r[i];
ans[i] = r[i];
while(!balloon.empty() and r[balloon.top()] <= ans[i]){
long double lo = 0, hi = ans[i] + 0.0001;
while(hi - lo > 0.0001){
long double mid = (hi + lo) / 2.0;
if(check(i, balloon.top(), mid)) lo = mid;
else hi = mid;
}
ans[i] = min(ans[i], lo);
if(ans[i] >= r[balloon.top()]) balloon.pop();
}
if(!balloon.empty()){
long double lo = 0, hi = ans[i] + 0.0001;
while(hi - lo > 0.0001){
long double mid = (hi + lo) / 2.0;
if(check(i, balloon.top(), mid)) lo = mid;
else hi = mid;
}
ans[i] = min(ans[i], lo);
}
balloon.push(i);
cout << ans[i] << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
2nd numbers differ - expected: '252735385.4379999936', found: '0.9333689377', error = '252735384.5046310425' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
5th numbers differ - expected: '0.1170000000', found: '1.0000000000', error = '0.8830000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
512 KB |
148th numbers differ - expected: '8.2380000000', found: '26.0000000000', error = '17.7620000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
49 ms |
1272 KB |
196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
140 ms |
2680 KB |
744th numbers differ - expected: '14594.0000000000', found: '12745.9183089851', error = '1848.0816910149' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
282 ms |
5172 KB |
7239th numbers differ - expected: '0.0590000000', found: '1.0000000000', error = '0.9410000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
322 ms |
6004 KB |
4651st numbers differ - expected: '0.4220000000', found: '1.0000000000', error = '0.5780000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
427 ms |
7840 KB |
1730th numbers differ - expected: '5.6890000000', found: '6.8058495467', error = '1.1168495467' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
487 ms |
9732 KB |
2718th numbers differ - expected: '2.2100000000', found: '3.0000000000', error = '0.7900000000' |
2 |
Halted |
0 ms |
0 KB |
- |