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;
int n, x;
stack<pair<int, double>> stk;
double r;
double ry(double rx, long long x, long long y) {
return ((x*x-2*x*y+y*y)/rx)/4;
}
double cmp(pair<int, double> e1, pair<int, double> e2, long long y) {
return (e2.second)*(1ll*e1.first*e1.first-2ll*e1.first*y+y*y) <= (e1.second)*(1ll*e2.first*e2.first-2ll*e2.first*y+y*y);
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
cin >> n;
while(n--) {
cin >> x >> r;
while(stk.size() > 1) {
auto e2 = stk.top(); stk.pop(); auto e1 = stk.top();
if(cmp(e1, e2, x)) continue;
else {
stk.push(e2);
break;
}
}
if(stk.empty()) stk.emplace(x, r);
else stk.emplace(x, min(ry(stk.top().second, stk.top().first, x), r));
cout << fixed << setprecision(3) << stk.top().second << '\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... |