#include<bits/stdc++.h>
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define mod 1'000'000'007
#define inf 1'000'000'000'000'00
#define pb push_back
#define vvi vector<vi>
#define fst ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int x[200005], r[200005];
signed main(){
fst
int n; cin >> n;
for(int i = 0; i < n; i++){
cin >> x[i] >> r[i];
}
vector<long double> ans(n);
long double mx = 1;
int px = 0;
for(int i = 0; i < n-1; i++){
ans[i] = r[i];
if(i != 0){
ans[i] = min(ans[i], (long double)(x[i] - px)*(x[i] - px)/(4*mx));
int d = x[i+1] - x[i];
if((long double)d*d/(4*ans[i]) < (long double)(x[i+1]-px)*(x[i+1]-px)/(4*mx)){
mx = ans[i];
px = x[i];
}
}
else{
px = x[i];
mx = ans[i];
}
}
ans[n-1] = min((long double)r[n-1], (long double)(x[n-1]-px)*(x[n-1]-px)/(4*mx));
cout << fixed << setprecision(3);
for(int i = 0; i < n; i++) cout << ans[i] << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |