#include<bits/stdc++.h>
#define sanastd using namespace std
sanastd;
const int MAXN = 1000 * 1000 + 10;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;
int n, r[MAXN], x[MAXN];
long double ans[MAXN];
stack <int> balloon;
long double ssq (long double m)
{
long double lo = 0, hi = m + 1;
while(hi - lo > 0.0001){
long double mid = (hi + lo) / 2.0;
if(mid * mid > m) hi = mid;
else lo = mid;
}
return lo;
}
bool check(int ind1, int ind2, double mid)
{
long double d = (x[ind1] - x[ind2]) * (x[ind1] - x[ind2]) + (ans[ind2] - mid) * (ans[ind2] - mid);
if(ssq(d) < mid + ans[ind2]) return 0;
else return 1;
}
int main ()
{
cout<<fixed<<setprecision(15);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> x[0] >> r[0];
balloon.push(0);
ans[0] = r[0];
cout << r[0] << endl;
for(int i = 1; i < n; i++){
cin >> x[i] >> r[i];
ans[i] = r[i];
while(!balloon.empty() and ans[balloon.top()] <= ans[i]){
long double d = (x[i] - x[balloon.top()]) * (x[i] - x[balloon.top()]) / ( ans[balloon.top()] * 4.0);
ans[i] = min(ans[i], d);
if(ans[i] >= ans[balloon.top()]) balloon.pop();
}
if(!balloon.empty()){
long double d = (x[i] - x[balloon.top()]) * (x[i] - x[balloon.top()]) / (ans[balloon.top()] * 4.0);
ans[i] = min(ans[i], d);
}
balloon.push(i);
cout << ans[i] << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
2nd numbers differ - expected: '252735385.4379999936', found: '0.9334151241', error = '252735384.5045848787' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
505 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
512 KB |
506th numbers differ - expected: '365.0000000000', found: '-2481854.0646065241', error = '2482219.0646065241' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
1400 KB |
655th numbers differ - expected: '591.0000000000', found: '-2402336.3030539565', error = '2402927.3030539565' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
72 ms |
2808 KB |
4th numbers differ - expected: '15396.0000000000', found: '-8148.5509720554', error = '23544.5509720554' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
146 ms |
5368 KB |
7234th numbers differ - expected: '7160.0000000000', found: '-2398141.9988687783', error = '2405301.9988687783' |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
168 ms |
6136 KB |
4643rd numbers differ - expected: '2427.0000000000', found: '-2355611.7017843765', error = '2358038.7017843765' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
231 ms |
8104 KB |
1734th numbers differ - expected: '1856.0220000000', found: '-2324667.3863617540', error = '2326523.4083617539' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
300 ms |
11248 KB |
2723rd numbers differ - expected: '859.0470000000', found: '-2333711.4845473454', error = '2334570.5315473452' |
2 |
Halted |
0 ms |
0 KB |
- |