#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 |
1 |
Correct |
1 ms |
212 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
996 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
2572 KB |
50000 numbers |
2 |
Correct |
51 ms |
2436 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
4496 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
5184 KB |
115362 numbers |
2 |
Correct |
125 ms |
5432 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
6500 KB |
154271 numbers |
2 |
Correct |
218 ms |
8612 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
202 ms |
7812 KB |
200000 numbers |
2 |
Correct |
206 ms |
8612 KB |
199945 numbers |