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 fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 1000000007
#define LOGN 12
#define MAXN 3000000
typedef long double ld;
ld find(ld r1, ll x1, ll x2) {
ll d_sq = (x2 - x1) * (x2 - x1);
ld ans = (d_sq * 1.0) / (4 * r1);
return ans;
}
int main() {
fast
int n;
cin >> n;
vector<pair<ll,ll>> bal(n+1);
vector<ld> ans(n+1);
for (int i = 1; i <= n; i++)
cin >> bal[i].f >> bal[i].s;
stack<pair<ll, ld>> st;
for (int i = 1; i <= n; i++) {
ans[i] = (ld)bal[i].s;
while (!st.empty()) {
pair<ll, ld> p = st.top();
ld q = find(p.s, p.f, bal[i].f);
if (q > ans[i]) {
break;
} else {
st.pop();
ans[i] = q;
}
}
st.push({bal[i].f, ans[i]});
}
cout << setprecision(10) << fixed;
for (int i = 1; i <= n; i++)
cout << ans[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... |