#include <iostream>
#include <stack>
using namespace std;
int coordinates[200000];
long double radius[200000];
long double compute_formula(int coordinate1, int coordinate2, long double r) {
long double l = (coordinate2 - coordinate1) / 2.;
return l * l / r;
}
int main() {
int n;
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> coordinates[i];
cin >> radius[i];
}
stack<int> st;
for(int i = 0; i < n; ++i) {
long double max_rad = radius[i];
while(!st.empty()) {
int j = st.top();
int coordinate_j = coordinates[j];
long double radius_j = radius[j];
max_rad = min(max_rad, compute_formula(coordinate_j, coordinates[i] ,radius_j));
if(max_rad > radius[j] - 1e-10) st.pop();
else {
break;
}
}
if(max_rad < radius[i]) {
radius[i] = max_rad;
}
printf("%.3Lf\n", radius[i]);
st.emplace(i);
}
}
# |
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 |
0 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 |
18 ms |
2908 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
3676 KB |
50000 numbers |
2 |
Correct |
37 ms |
3924 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
4944 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
4944 KB |
115362 numbers |
2 |
Correct |
88 ms |
6192 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
5968 KB |
154271 numbers |
2 |
Correct |
149 ms |
9300 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
143 ms |
7244 KB |
200000 numbers |
2 |
Correct |
156 ms |
9300 KB |
199945 numbers |