# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
754410 | PanosPask | Balloons (CEOI11_bal) | C++14 | 118 ms | 7100 KiB |
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>
#define pb push_back
using namespace std;
typedef long long ll;
int n;
vector<int> active_circles;
vector<long double> radius;
vector<int> maxradius;
vector<int> position;
long double find_r2(int x1, long double r1, int x2)
{
return ((ll)(x1 - x2) * (x1 - x2)) / (4 * r1);
}
long double allowed_radius(int i, int j)
{
return find_r2(position[i], radius[i], position[j]);
}
int main(void)
{
scanf("%d", &n);
position.resize(n);
maxradius.resize(n);
radius.resize(n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &position[i], &maxradius[i]);
}
for (int i = 0; i < n; i++) {
bool foundbreak = false;
while (active_circles.size() >= 2 && !foundbreak) {
int mid = active_circles.back();
int prv = active_circles[active_circles.size() - 2];
if (allowed_radius(prv, i) <= allowed_radius(mid, i)) {
active_circles.pop_back();
}
else
foundbreak = true;
}
radius[i] = maxradius[i];
if (!active_circles.empty())
radius[i] = min(radius[i], allowed_radius(active_circles.back(), i));
while (!active_circles.empty() && radius[active_circles.back()] <= radius[i])
active_circles.pop_back();
active_circles.pb(i);
printf("%.3Lf\n", radius[i]);
}
return 0;
}
Compilation message (stderr)
# | 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... |