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;
using ll = long long;
double calc_r(array<double, 2> a, double x) {
return (a[0] - x) * (a[0] - x) / (4 * a[1]);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
stack<array<double, 2>> s;
cout << fixed << setprecision(5);
for(int i = 0; i < n; i++) {
double x, r;
cin >> x >> r;
double mx_r = r;
while(!s.empty()) {
auto last = s.top();
double curr = calc_r(last, x);
mx_r = min(mx_r, curr);
if(mx_r >= last[1]) {
s.pop();
continue;
}
break;
}
s.push({x, mx_r});
cout << mx_r << '\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... |