This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
void solve(){
int n;cin>>n;
vector<int>x(n), limit(n);
for(int i=0;i<n;i++)cin>>x[i]>>limit[i];
vector<double>radius(n);
stack<int>st;
for(int i=0;i<n;i++){
double val_i = 1.0*limit[i];
while(!st.empty()){
// just touching the balloon;
double curr = 1.0*(x[i]-x[st.top()])*(x[i]-x[st.top()])/(4.0*radius[st.top()]);
if(curr < val_i){
val_i = curr;
}
if(val_i >= radius[st.top()]){
st.pop();
}else{
break;
}
}
st.push(i);
radius[i]=val_i;
}
for(int i=0;i<n;i++)cout<<fixed<<setprecision(9)<<radius[i]<<" ";
cout<<endl;
}
int main(){
int tt=1;
//cin>>tt;
while(tt--){
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... |