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;
long double dist(pair<long long, long long> a, pair<long long, long long> b) {
return (a.first - b.first) * (a.first - b.first) / (long double)(4 * b.second);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(3);
int n;
cin >> n;
vector<pair<long long, long long>> v(n);
for (int i = 0; i < n; i++)
cin >> v[i].first >> v[i].second;
vector<long double> ans(n);
stack<pair<long long, long long>> s;
for (int i = 0; i < n; i++) {
if (s.size() == 0) {
s.push(v[i]);
ans[i] = v[i].second;
} else {
ans[i] = min((long double)(v[i].second), dist(v[i], s.top()));
while (s.size() && dist(v[i], s.top()) >= ans[i] && v[i].second > s.top().second) {
s.pop();
ans[i] = dist(v[i], s.top());
}
s.push(v[i]);
}
}
for (auto i : ans)
cout << i << '\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... |