This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* Online C++ Compiler and Editor */
#include <bits/stdc++.h>
#define f first
#define s second
typedef long double ld;
using namespace std;
int main()
{
int n; cin >> n;
vector<ld> x(n); vector<ld> r(n);
stack<pair<ld, ld>> mono;
auto eval = [&](pair<ld, ld> prev, ld x) -> ld {
return (prev.f - x) * (prev.f - x) / (4 * prev.s);
};
for (int i = 0; i < n; i++){
cin >> x[i] >> r[i];
while (!mono.empty()){
ld val = eval(mono.top(), x[i]);
r[i] = min(r[i], val);
if (mono.top().s <= val) {
mono.pop();
} else {
break;
}
}
mono.push({x[i], r[i]});
}
cout << fixed << setprecision(4) << '\n';
for (int i = 0; i < n; i++) cout << r[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... |