이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |