#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
#define N 200005
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")
int n, x[N];
f80 r[N];
struct line
{
f80 m, c;
int i;
f80 operator[](i64 x) { return m*x+c; }
f80 intersectx(const line &l) { return f80(l.c - c) / (m - l.m); }
};
deque<line> lc;
void add(line k)
{
while (lc.size())
{
if (lc.back().m >= k.m) lc.pop_back();
else if (lc.size() > 1 && k.intersectx(lc.back()) <= k.intersectx(lc[lc.size()-2])) lc.pop_back();
else break;
}
lc.push_back(k);
}
f80 qry(i64 x)
{
u64 l = 1, r = lc.size(), z = 0;
for (; l <= r;)
{
u64 m = (l+r)/2;
if (lc[m].intersectx(lc[m-1]) >= x) z = m, r = m - 1;
else l = m + 1;
}
return lc[z].i;
}
int main()
{
ShinLena;
cin >> n;
for (int i = 0; i < n; ++i) cin >> x[i] >> r[i];
add({-f80(*x)/r[0], 1L*f80(*x**x)/r[0], 0});
for (int i = 1; i < n; ++i)
{
int j = qry(x[i]);
f80 A = (1L * x[i] * x[i] + 1L * x[j] * x[j] - 2L * x[i] * x[j]) / (4L * r[j]);
r[i] = min(r[i], A);
add({-f80(x[i])/r[i], f80(x[i]*x[i]) / r[i], i});
}
cout << fixed << setprecision(3);
for (int i = 0; i < n; ++i)
cout << r[i] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
4th numbers differ - expected: '1.8420000000', found: '87.0000000000', error = '85.1580000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
80th numbers differ - expected: '33.0560000000', found: '140.0000000000', error = '106.9440000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
2884 KB |
138th numbers differ - expected: '56.3670000000', found: '256.0650000000', error = '199.6980000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
3220 KB |
1680th numbers differ - expected: '13546.0030000000', found: '23224.0000000000', error = '9677.9970000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
80 ms |
3920 KB |
1985th numbers differ - expected: '5763.0020000000', found: '5764.0000000000', error = '0.9980000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
87 ms |
4188 KB |
513th numbers differ - expected: '4492.0080000000', found: '4494.0000000000', error = '1.9920000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
4772 KB |
399th numbers differ - expected: '1446.0110000000', found: '5720.0000000000', error = '4273.9890000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
5888 KB |
477th numbers differ - expected: '2436.0070000000', found: '9767.9900000000', error = '7331.9830000000' |
2 |
Halted |
0 ms |
0 KB |
- |