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 pii pair<int, double>
#define ll long long
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cout << fixed;
cout << setprecision(3);
int n;
cin >> n;
stack<pii> balloons;
for (int i = 0; i < n; i++)
{
int a, b;
cin >> a >> b;
double sol = b;
while (balloons.size())
{
ll dn = a-balloons.top().first;
double r = balloons.top().second;
if ((r+b)*(r+b) >= dn*dn+(r-b)*(r-b))
{
sol = min(sol, (dn*dn)/(4*r));
}
if (r>sol)break;
balloons.pop();
}
balloons.push({a, sol});
cout << sol << "\n";
}
}
# | 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... |