#include <vector>
#include <iostream>
#include <stack>
#include <iomanip>
using namespace std;
struct ustruct
{
int x;
long double r;
};
signed main()
{
int n;
cin >> n;
int x[n], maxr[n];
for (int i = 0; i < n; i++)
{
cin >> x[i] >> maxr[i];
}
stack<ustruct> st;
// cout<<__cplusplus<<endl;
vector<double> ans(n, 0.0);
for (int i = 0; i < n; i++)
{
if (st.empty())
{
st.push({x[i],(long double)maxr[i]});
ans[i] = maxr[i];
}
else
{
while (!st.empty())
{
int prevx = st.top().x;
long double prevr = st.top().r;
long double curr;
long double wantr = ((x[i] - prevx + 0.0) * (x[i] - prevx + 0.0)) / (4 * prevr + 0.0);
if (wantr >= maxr[i])
{
curr = maxr[i];
}
else
{
curr = wantr;
}
if (curr >= prevr)
{
st.pop();
if (st.empty())
{
st.push({x[i], (long double)maxr[i]});
// st.push({x[i], (double)maxr[i]});
ans[i] = st.top().r;
break;
}
}
else
{
//
st.push({x[i], (long double)(curr)});
ans[i] = st.top().r;
break;
}
}
}
}
cout << fixed << setprecision(3);
for (auto i : ans)
{
cout << i << " ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
2nd numbers differ - expected: '252735385.4379999936', found: '1000000000.0000000000', error = '747264614.5620000362' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
6th numbers differ - expected: '213.0000000000', found: '238.0000000000', error = '25.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
312 KB |
79th numbers differ - expected: '36.0070000000', found: '2766.0000000000', error = '2729.9930000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
772 KB |
137th numbers differ - expected: '67.1010000000', found: '3129.0000000000', error = '3061.8990000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
80 ms |
1612 KB |
250th numbers differ - expected: '15134.0000000000', found: '18307.0000000000', error = '3173.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
122 ms |
2964 KB |
162nd numbers differ - expected: '7765.0000000000', found: '14571.0000000000', error = '6806.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
146 ms |
3368 KB |
510th numbers differ - expected: '4505.0010000000', found: '13465.0000000000', error = '8959.9990000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
193 ms |
4228 KB |
161st numbers differ - expected: '1703.0000000000', found: '4036.0000000000', error = '2333.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
227 ms |
5204 KB |
248th numbers differ - expected: '2694.0020000000', found: '8658.0000000000', error = '5963.9980000000' |
2 |
Halted |
0 ms |
0 KB |
- |