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;
const double INF=1e9+7;
double calc(double p1,double r1,double p2){
if(r1==0){
return 0;
}
return double ((p2-p1)*(p2-p1))/(4*r1);
}
int main(){
int n;
cin>>n;
vector<double> pos(n);
vector<double> maxr(n);//maximo
vector<double> raio(n);
for(int i=0;i<n;i++){
cin>>pos[i]>>maxr[i];
}
vector<pair<int,int>> fila;
cout<<fixed<<setprecision(3);
for(int i=0;i<n;i++){
while(fila.size()>1 && calc(fila.back().first,fila.back().second,pos[i])>calc(fila[fila.size()-2].first,fila[fila.size()-2].second,pos[i])){
fila.pop_back();
}
if(fila.empty()){
raio[i]=maxr[i];
}
else if(calc(fila.back().first,fila.back().second,pos[i])<maxr[i]){
raio[i]=calc(fila.back().first,fila.back().second,pos[i]);
}
else{
raio[i]=maxr[i];
}
fila.push_back({pos[i],raio[i]});
}
for(int i=0;i<n;i++){
cout<<raio[i]<<"\n";
}
}
# | 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... |