This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// https://oj.uz/problem/view/CEOI11_bal
// Balloons
#include <bits/stdc++.h>
#define x first
#define r second
using namespace std;
typedef vector<int> vi;
typedef long double ld;
int main() {
int n;
cin >> n;
vector<pair<int, ld>> balls(n);
for (int i = 0; i < n; i++) {
cin >> balls[i].x >> balls[i].r;
}
// Stack algorithm
stack<pair<int, ld>> st;
vector<ld> radii(n);
for (int i = 0; i < n; i++) {
ld max_rad = balls[i].r;
while (!st.empty()) {
pair<int, ld> top = st.top();
max_rad = min(pow(balls[i].x - top.x, 2) / (4 * top.r), max_rad);
if (max_rad >= top.r) {
st.pop();
} else {
break;
}
}
st.push(make_pair(balls[i].x, max_rad));
radii[i] = max_rad;
}
for (ld r : radii) {
cout << r << "\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... |