#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define f first
#define s second
#define PF push_front
#define PB push_back
#define MP make_pair
#define pi pair<int, int>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define max(a, b) ((a > b)? a : b)
#define min(a, b) ((a < b)? a : b)
#define max3(a, b, c) max(max(a, b), c)
#define min3(a, b, c) min(min(a, b), c)
const int N = 2e5 + 5;
const int M = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll int INF = 1e18;
vector<ld> ans(N), v(N), r(N);
ld get_radius(int a, int b){
ld dis = v[b] - v[a];
ld res = (dis*dis)/(4*ans[a]);
res = min(res, r[b]);
return res;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
// ifstream cin();
// ofstream cout();
int n;
cin >> n;
for(int i = 1; i <= n; i++) cin >> v[i] >> r[i];
stack<int> st;
st.push(1);
ans[1] = r[1];
for(int i = 2; i <= n; i++){
ld cur = INF;
int buffer;
while(!st.empty()){
ld nxt = get_radius(st.top(), i);
if(nxt >= cur) break;
cur = nxt;
buffer = st.top();
st.pop();
}
st.push(buffer);
st.push(i);
ans[i] = cur;
}
cout << fixed << setprecision(3);
for(int i = 1; i <= n; i++) cout << ans[i] << endl;
}
# | 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... |