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;
#define ss second
#define ff first
typedef long long ll;
typedef long double ld;
#define int ll
ld check(ld lr, ld nx, ld lx){
ld up = abs(nx-lx);
ld denominator = 4*lr;
return (up*up)/denominator;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<ld> answer(n);
stack<pair<ld,ld>> st;
for(int i = 0; i < n; ++i){
ld cor, mr;
cin >> cor >> mr;
if(st.empty()){
answer[i] = mr;
st.push({mr,cor});
}else{
while(true){
auto &[lr, lx] = st.top();
mr = min(mr, check(lr,cor,lx));
if(mr>=lr){
st.pop();
if(st.empty()){
answer[i] = mr;
st.push({mr,cor});
break;
}
}else{
st.push({mr,cor});
answer[i] = mr;
break;
}
}
}
}
for(int i = 0; i < n; ++i){
cout << answer[i] << '\n';
}
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... |