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 i64 = long long;
const double eps = 1E-4;
double solve(double x1, double r, double x2) {
double low = 0, high = 1E9, R = 0;
while (high - low >= eps) {
double mid = (low + high) / 2;
double dist = std::sqrt((long double) (x1 - x2) * (x1 - x2) + (long double) (r - mid) * (r - mid));
if (dist >= r + mid) {
R = mid;
low = mid;
} else {
high = mid;
}
}
return R;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<double> x(n), r(n);
for (int i = 0; i < n; i++) {
std::cin >> x[i] >> r[i];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
r[i] = std::min(r[i], solve(x[j], r[j], x[i]));
}
std::cout << std::fixed << std::setprecision(3) << r[i] << "\n";
}
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... |