#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, x[N], r[N];
long double ans[N];
long double calc(int i, int j){
double x1 = x[i], y1 = ans[i];
double x2 = x[j];
return (x1 * x1 + x2 * x2 - 2 * x1 * x2 ) / (4 * y1);
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x[i] >> r[i];
ans[i] = r[i];
}
stack<int> st;
for(int i = 1; i <= n; i++){
long double reach = r[i];
for(int j = i - 1; j >= 0; j--){
if(x[i] - x[j] >= reach) break;
reach = min(reach, calc(j, i));
}
ans[i] = reach;
}
for(int i = 1; i <= n; i++)
cout << setprecision(3) << fixed << ans[i] << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
2nd numbers differ - expected: '4.1670000000', found: '7.0000000000', error = '2.8330000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
504 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
512 KB |
2nd numbers differ - expected: '122.0020000000', found: '123.0000000000', error = '0.9980000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
1144 KB |
2nd numbers differ - expected: '212.0010000000', found: '213.0000000000', error = '0.9990000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
1872 KB |
2nd numbers differ - expected: '15398.0000000000', found: '24984.0000000000', error = '9586.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
4644 KB |
2nd numbers differ - expected: '7937.0000000000', found: '10352.0000000000', error = '2415.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
4676 KB |
2nd numbers differ - expected: '5059.0000000000', found: '5060.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
87 ms |
6216 KB |
2nd numbers differ - expected: '1873.0000000000', found: '1874.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
102 ms |
6472 KB |
2nd numbers differ - expected: '2961.0000000000', found: '2962.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |