#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define FOR(i, a, b, s) for (int i = (a); i < (b); i += s)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define pii pair<ld,ld>
#define mp make_pair
#define f first
#define s second
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
ld x, r;
stack<pii> s;
cout << fixed << setprecision(3);
F0R(i,n) {
cin >> x >> r;
ld r1 = r;
while (s.size()) {
pii p = s.top();
ld cand = min((ld)(x-p.f)*(x-p.f)/(p.s*4.0),r);
if (cand <= r1) {r1 = cand;}
//else {while (s.size()&&s.top().s <= r1) {s.pop();} break;}
if (r1 >= p.s) {s.pop();}
else {break;}
} s.push({x,r1});
cout << r1 << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 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 |
15 ms |
860 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
1592 KB |
50000 numbers |
2 |
Correct |
33 ms |
1372 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
2384 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
2640 KB |
115362 numbers |
2 |
Correct |
86 ms |
2536 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
3156 KB |
154271 numbers |
2 |
Correct |
131 ms |
5456 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
147 ms |
3680 KB |
200000 numbers |
2 |
Correct |
130 ms |
5564 KB |
199945 numbers |