이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
double maxRadius(int x1, int x2, double r1) {
/**
* (x2 - x1)^2 + (r2 - r1)^2 = (r2 + r1)^2
* (x2 - x1)^2 = 4 r1 r2
*/
return 1LL * (x2 - x1) * (x2 - x1) / (4 * r1);
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n; cin >> n;
vector<pair<int, double>> a(n); // [x, maxRadius]
for (auto &[x, r]: a) cin >> x >> r;
stack<pair<int, double>> st; // [position, radius]
cout << fixed << setprecision(3);
for (int i = 0; i < n; i++) {
auto [x2, maxR2] = a[i];
double r2 = maxR2;
while (not st.empty()) {
auto [x1, r1] = st.top();
r2 = min(r2, maxRadius(x1, x2, r1));
if (r2 < r1) break;
st.pop();
}
st.emplace(x2, r2);
cout << r2 << '\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... |