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 ld long double
ld calc (pair <ld, ld> x, ld a) {
return (a - x.first) * (a - x.first) / (4 * x.second);
}
int main () {
cout << fixed << setprecision(9);
int n;
cin >> n;
ld arr[n][2] = {};
for (int i = 0; i < n; i++) cin >> arr[i][0] >> arr[i][1];
stack <pair <ld, ld>> cur;
ld ans[n];
ans[0] = arr[0][1];
cur.push({arr[0][0], ans[0]});
for (int i = 1; i < n; i++) {
ans[i] = arr[i][1];
while (!cur.empty()) {
auto k = cur.top();
ans[i] = min(ans[i], calc(k, arr[i][0]));
if (k.second <= ans[i]) cur.pop();
else break;
}
cur.push({arr[i][0], ans[i]});
}
for (int i = 0; i < n; i++) {
cout << ans[i] << " ";
}
cout << '\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... |