#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) int32_t(s.length())
#define MASK(k)(1LL<<(k))
#define TASK "test"
#define int long long
#define double long double
using namespace std;
typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;
const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 200005;
int n;
pdd a[MX];
pdd v[MX];
void nhap(){
cin >> n;
for(int i=1; i<=n; i++) cin >> a[i].fi >> a[i].se;
}
double sqr(double x){
return x*x;
}
double euler(pdd a, pdd b){
return sqrt(sqr(a.fi - b.fi) + sqr(a.se - b.se));
}
double dis(pdd ball, double p){
double lo=0, hi=INF;
for(int t=0; t<45; t++){
double mid = (lo+hi)/2;
if(euler(ball, {p, mid}) >= mid + ball.se) lo = mid;
else hi = mid;
}
return (lo + hi)/2;
}
void solve(){
stack<pdd> v;
for(int i=1; i<=n; i++){
double val = a[i].se;
while(v.size()){
val = min({val, dis(v.top(), a[i].fi)});
if(val >= v.top().se) v.pop();
else break;
}
v.push({a[i].fi, val});
cout << fixed << setprecision(3) << val << '\n';
}
}
int32_t main(){
fastIO;
//file(TASK);
nhap();
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
505 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2396 KB |
2000 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
56 ms |
5136 KB |
1450th numbers differ - expected: '487.2410000000', found: '487.2390000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
121 ms |
5380 KB |
50000 numbers |
2 |
Correct |
122 ms |
4708 KB |
49912 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
250 ms |
7848 KB |
17505th numbers differ - expected: '1940.1430000000', found: '1940.1400000000', error = '0.0030000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
295 ms |
7900 KB |
32877th numbers differ - expected: '9312.0980000000', found: '9312.0960000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
392 ms |
10348 KB |
1751st numbers differ - expected: '1868.0130000000', found: '1868.0110000000', error = '0.0020000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
489 ms |
10324 KB |
2723rd numbers differ - expected: '859.0470000000', found: '859.0580000000', error = '0.0110000000' |
2 |
Halted |
0 ms |
0 KB |
- |