#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
void init(){
}
const int N = (int) 2e5 + 8;
const int mod = (int)1e9+7;
int x[N] , r[N];
int n ;
stack<pair<int,int>> st;
int inflate( int xx , double rr ) {
// for touching circle
// max radius will be r = ( x1 - x) ^2 / 4*r1
// also observation
// x2 > x1 for any x > x2 we have (x1-x)^2 > (x2-x)^2
// along with r1<=r2 then only r2 will require for calculation of answer for x
while( !st.empty() ){
int x1 = st.top().first , r1 = st.top().second;
rr = min ( rr , (double)(x1-xx)*(x1-xx)/(4.0*r1));
if( rr >= r1 ) {
st.pop();
}else break;
}
st.push({xx,rr});
cout<<fixed<<rr<<endl;
return 0;
}
void solve(){
cin>>n;
for( int i = 0 ; i< n ;i ++) {
cin>>x[i]>>r[i];
}
for( int i =0 ;i < n ; i ++) {
inflate( x[i] , r[i] ) ;
}
}
int32_t main(){
FAST;
init();
int t=1;
/* cin>>t; */
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
8th numbers differ - expected: '8.7410000000', found: '9.0909090000', error = '0.3499090000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
13th numbers differ - expected: '2.3960000000', found: '2.4500000000', error = '0.0540000000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
332 KB |
3rd numbers differ - expected: '121.0000000000', found: '121.0020490000', error = '0.0020490000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
1012 KB |
71st numbers differ - expected: '136.0000000000', found: '136.0018250000', error = '0.0018250000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
132 ms |
2508 KB |
254th numbers differ - expected: '15129.9990000000', found: '15130.0013390000', error = '0.0023390000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
278 ms |
4612 KB |
286th numbers differ - expected: '7633.9990000000', found: '7634.0008190000', error = '0.0018190000' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
321 ms |
5276 KB |
512th numbers differ - expected: '4502.9990000000', found: '4503.0045060000', error = '0.0055060000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
434 ms |
7012 KB |
165th numbers differ - expected: '1698.9980000000', found: '1699.0001470000', error = '0.0021470000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
524 ms |
8292 KB |
249th numbers differ - expected: '2683.0090000000', found: '2683.0112290000', error = '0.0022290000' |
2 |
Halted |
0 ms |
0 KB |
- |