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 all(x) begin(x), end(x)
#define allr(x, r) begin(x), begin(x) + (r)
using ll = long long;
using ld = long double;
ld calc_r(pair<ld, ld> a, ld bx)
{
return (a.first - bx) * (a.first - bx) / (4 * a.second);
}
int main()
{
#if defined(DEBUG) && !defined(ONLINE_JUDGE)
// DEBUG
cerr << "DEBUG flag set - see test.out for output\n";
freopen("/home/chuang/shared-drives/G:/repos/cp/ois/ceoi11/balloons/test.in", "r", stdin);
freopen("/home/chuang/shared-drives/G:/repos/cp/ois/ceoi11/balloons/test.out", "w", stdout);
#else
cin.tie(0)->sync_with_stdio(false);
#endif
int n;
cin >> n;
vector<ld> res(n);
stack<pair<ld, ld>> to_check;
for (int i = 0; i < n; i++)
{
ld x, r;
cin >> x >> r;
ld max_r = r;
while (!to_check.empty())
{
pair<ld, ld> last = to_check.top();
ld to_last_r = calc_r(last, x);
max_r = min(max_r, to_last_r);
if (max_r >= last.second)
{
to_check.pop();
continue;
}
else
{
break;
}
}
to_check.push({x,max_r});
res[i] = max_r;
}
cout << fixed << setprecision(3);
for (auto &r : res)
{
cout << r << "\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... |