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 int long long int
struct bal {
int x, r;
};
void solve() {
int n;
cin >> n;
vector<long double> ans(n);
vector<bal> p(n);
for (int i = 0; i < n; i++) {
cin >> p[i].x >> p[i].r;
ans[i] = p[i].r;
}
vector<pair<long double, int>> st;
for (int i = 0; i < n; i++) {
while(!st.empty()) {
long double delta = abs(p[i].x-p[st.back().second].x);
ans[i] = min(ans[i], (long double) delta*delta/((long double)4.0L*st.back().first));
if (ans[i] >= st.back().first) {
st.pop_back();
} else {
break;
}
}
st.push_back({ans[i], i});
}
for (int i = 0; i < n; i++) {
cout << fixed << setprecision(3) << ans[i] << endl;
}
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
t = 1;
while(t--) {
solve();
}
}
# | 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... |