#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;
while(hi - lo > 0.0001){
long double mid = (hi + lo) / 2;
if(mid * mid > m) hi = mid;
else hi = mid;
}
return hi;
}
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 r[balloon.top()] <= ans[i]){
long double lo = 0, hi = ans[i] + 0.0001;
while(hi - lo > 0.0001){
long double mid = (hi + lo) / 2.0;
if(check(i, balloon.top(), mid)) lo = mid;
else hi = mid;
}
ans[i] = min(ans[i], lo);
if(ans[i] >= r[balloon.top()]) balloon.pop();
}
if(!balloon.empty()){
long double lo = 0, hi = ans[i] + 0.0001;
while(hi - lo > 0.0001){
long double mid = (hi + lo) / 2.0;
if(check(i, balloon.top(), mid)) lo = mid;
else hi = mid;
}
ans[i] = min(ans[i], lo);
}
balloon.push(i);
cout << ans[i] << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
2nd numbers differ - expected: '4.1670000000', found: '0.0000000000', error = '4.1670000000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
2nd numbers differ - expected: '252735385.4379999936', found: '0.0000000000', error = '252735385.4379999936' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
3rd numbers differ - expected: '0.0420000000', found: '0.0000000000', error = '0.0420000000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
384 KB |
2nd numbers differ - expected: '122.0020000000', found: '0.0000000000', error = '122.0020000000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
95 ms |
1272 KB |
2nd numbers differ - expected: '212.0010000000', found: '0.0000000000', error = '212.0010000000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
288 ms |
2672 KB |
2nd numbers differ - expected: '15398.0000000000', found: '0.0000000000', error = '15398.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
609 ms |
4984 KB |
2nd numbers differ - expected: '7937.0000000000', found: '0.0000000000', error = '7937.0000000000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
723 ms |
5752 KB |
2nd numbers differ - expected: '5059.0000000000', found: '0.0000000000', error = '5059.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
964 ms |
7416 KB |
2nd numbers differ - expected: '1873.0000000000', found: '0.0000000000', error = '1873.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1006 ms |
9596 KB |
2nd numbers differ - expected: '2961.0000000000', found: '0.0000000000', error = '2961.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |