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 N 200005
#define fi first
#define se second
typedef pair<double, double> ii;
double res[N];
int n;
double cal(ii a, double bx){
return (bx - a.fi) * (bx - a.fi) / (4 * a.se);
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
stack<ii> st;
cin >> n;
for (int i = 1; i <= n; i++){
double r, x;
cin >> x >> r;
double mi = r;
while (!st.empty()){
ii tmp = st.top();
mi = min(mi, cal(tmp, x));
if (mi >= tmp.se) st.pop();
else break;
}
st.push({x, mi});
res[i] = mi;
}
cout << fixed << setprecision(3) ;
for (int i = 1; i <= n; i++){
cout << res[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... |