#include <bits/stdc++.h>
using namespace std;
const int nx=2e5+5;
double n, x[nx], mx[nx];
double dp[nx];
multiset<pair<double, int>> ms;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) cin>>x[i]>>mx[i];
for (int i=1; i<=n; i++)
{
if (ms.empty()) dp[i]=mx[i], ms.insert({DBL_MAX, i});
else
{
auto itr=ms.lower_bound({x[i], 0});
dp[i]=min(double(mx[i]), ((x[i]-x[itr->second])*(x[i]-x[itr->second]))/(4*dp[itr->second]));
while (dp[ms.begin()->second]<=dp[i]&&!ms.empty()) ms.erase(ms.begin());
if (ms.empty()) ms.insert({DBL_MAX, i});
else
{
int l=ms.begin()->second;
double a=dp[i]-dp[l], b=-2*(dp[i]*x[l]-dp[l]*x[i]), c=dp[i]*x[l]*x[l]-dp[l]*x[i]*x[i];
double tmp=max((-b+sqrt(b*b-4*a*c))/(2*a), (-b-sqrt(b*b-4*a*c))/(2*a));
ms.insert({tmp, i});
}
}
//cout<<i<<'\n';
//for (auto [x, y]:ms) cout<<x<<' '<<y<<'\n';
}
for (int i=1; i<=n; i++) printf("%.3f\n", dp[i]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
14th numbers differ - expected: '2.6090000000', found: '7.0410000000', error = '4.4320000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4444 KB |
7th numbers differ - expected: '115.0000000000', found: '117.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
4952 KB |
12th numbers differ - expected: '200.0000000000', found: '202.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
5980 KB |
41st numbers differ - expected: '15358.0000000000', found: '22549.0000000000', error = '7191.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
76 ms |
7480 KB |
14th numbers differ - expected: '7919.0000000000', found: '7920.0000000000', error = '1.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
96 ms |
8640 KB |
6th numbers differ - expected: '5053.0000000000', found: '5055.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
125 ms |
11344 KB |
49th numbers differ - expected: '1824.0000000000', found: '1826.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
165 ms |
12912 KB |
12th numbers differ - expected: '2950.0000000000', found: '2952.0000000000', error = '2.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |