#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 |
10th numbers differ - expected: '0.5150000000', found: '69.0000000000', error = '68.4850000000' |
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 |
4th numbers differ - expected: '0.0950000000', found: '3.0000000000', error = '2.9050000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
600 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 |
15 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 |
39 ms |
3164 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 |
76 ms |
3800 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 |
88 ms |
3992 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 |
127 ms |
5000 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 |
144 ms |
5900 KB |
3rd numbers differ - expected: '2960.0000000000', found: '2962.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |