#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pdd pair<long double, long double>
const int sz = 1e6 + 5;
pdd a[sz];
long double f[sz];
long double dist(long double x, long double y, long double u, long double v){
x = x - u;
y = y - v;
return sqrt(x*x + y*y);
}
long double bs(pdd ball, long double p){
long double l = 0, r = 1e9;
long double x, y;
tie(x, y) = ball;
for(int i=1;i<=60;++i){
long double mid = (l + r) / 2;
if(dist(x, y, p, mid) >= mid + y){
l = mid;
}
else{
r = mid;
}
}
return (l + r) / 2;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("main.inp","r",stdin);
// freopen("main.out","w",stdout);
int n;
cin>>n;
stack<int> st;
for(int i=1;i<=n;++i){
cin >> a[i].first >> a[i].second;
while(st.size()){
a[i].second = min(a[i].second, bs(a[st.top()], a[i].first));
if(a[i].second >= a[st.top()].second){
st.pop();
}
else{
break;
}
}
st.push(i);
cout<< fixed << setprecision(3) << a[i].second<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2396 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
2576 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
149 ms |
4972 KB |
50000 numbers |
2 |
Correct |
152 ms |
4688 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
309 ms |
7496 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
352 ms |
7636 KB |
115362 numbers |
2 |
Correct |
368 ms |
9716 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
475 ms |
8428 KB |
154271 numbers |
2 |
Correct |
607 ms |
13660 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
613 ms |
11604 KB |
200000 numbers |
2 |
Correct |
610 ms |
13652 KB |
199945 numbers |