#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using d64 = long double;
i64 sq(int a) {
return 1LL * a * a;
}
d64 calc(int ax, int bx, d64 ar) {
return d64(sq(bx - ax)) / (4 * ar);
}
#define ONLINE_JUDGE
void solve() {
int n;
cin >> n;
vector <int> x(n +1);
vector <d64> r(n +1);
for(int i = 1; i <= n; i++) {
cin >> x[i] >> r[i];
}
cout << fixed << setprecision(9);
stack <int> st;
for(int i = 1; i <= n; i++) {
while(!st.empty()) {
int j = st.top();
r[i] = min(r[i], calc(x[j], x[i], r[j]));
if(r[i] >= r[j]) {
st.pop();
} else {
break;
}
}
st.emplace(i);
cout << r[i] << "\n";
}
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
for(int i = 1; i <= t; i++) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
976 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
1960 KB |
50000 numbers |
2 |
Correct |
34 ms |
2804 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
3708 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
4436 KB |
115362 numbers |
2 |
Correct |
82 ms |
6528 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
5752 KB |
154271 numbers |
2 |
Correct |
134 ms |
10592 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
147 ms |
6992 KB |
200000 numbers |
2 |
Correct |
138 ms |
10580 KB |
199945 numbers |