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;
void subtask1 (vector<pair<double, double>> info) {
vector<double> ans(n);
ans[0] = info[0].second;
for (int i = 1; i < n; i++) {
double pans = 1e9;
for (int j = 0; j < i; j++)
pans = min(pans, (info[i].first - info[j].first) * (info[i].first - info[j].first) / (4 * ans[j]));
ans[i] = min(pans, info[i].second);
}
for (auto x: ans) printf("%.3lf\n", x);
}
void subtask2 (vector<pair<double, double>> info) {
vector<double> ans(n);
vector<pair<double, double>> s;
for (int i = 0; i < n; i++) {
double estimate = info[i].second;
while (s.size()) {
double x1mx2 = (info[i].first - s.back().first);
estimate = x1mx2 * x1mx2 / (4 * s.back().second);
//cout << s.back().second << " " << estimate << " ";
if (estimate <= info[i].second) s.pop_back();
else break;
}
ans[i] = min(estimate, info[i].second);
s.push_back({info[i].first, ans[i]});
printf("%.3lf\n", ans[i]);
}
}
int main (void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
vector<pair<double, double>> info(n);
for (int i = 0; i < n; i++) {
cin >> info[i].first >> info[i].second;
}
subtask2(info);
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... |