#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, l = m + 1;
else r = 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 |
1 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 |
344 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
7th numbers differ - expected: '0.0010000000', found: '9.0000000000', error = '8.9990000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
3rd numbers differ - expected: '121.0000000000', found: '123.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
2908 KB |
3rd numbers differ - expected: '211.0000000000', found: '213.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
3152 KB |
5th numbers differ - expected: '15395.0000000000', found: '15396.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
77 ms |
3860 KB |
3rd numbers differ - expected: '7936.0000000000', found: '10352.0000000000', error = '2416.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
86 ms |
3972 KB |
5th numbers differ - expected: '5054.0000000000', found: '5055.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
126 ms |
4892 KB |
3rd numbers differ - expected: '1872.0000000000', found: '1874.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
146 ms |
5992 KB |
3rd numbers differ - expected: '2960.0000000000', found: '2962.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |