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