#include "bits/stdc++.h"
using namespace std;
long double dist(pair<long long, long double> a, pair<long long, long double> b) {
return (a.first - b.first) * (a.first - b.first) / (long double)(4 * b.second);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(3);
int n;
cin >> n;
vector<pair<long long, long double>> v(n);
for (int i = 0; i < n; i++)
cin >> v[i].first >> v[i].second;
vector<long double> ans(n, 1e9);
stack<pair<long long, long double>> s;
for (int i = 0; i < n; i++) {
if (s.size() == 0) {
s.push(v[i]);
ans[i] = v[i].second;
} else {
ans[i] = min((long double)v[i].second, dist(v[i], s.top()));
while (s.size() > 1 && s.top().second < ans[i]) {
s.pop();
ans[i] = min(ans[i], dist(v[i], s.top()));
}
s.push({v[i].first, ans[i]});
}
}
for (auto i : ans)
cout << i << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
340 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
1364 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
3352 KB |
50000 numbers |
2 |
Correct |
47 ms |
3736 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
6128 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
7128 KB |
115362 numbers |
2 |
Correct |
106 ms |
8672 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
144 ms |
9136 KB |
154271 numbers |
2 |
Correct |
183 ms |
14232 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
172 ms |
11412 KB |
200000 numbers |
2 |
Correct |
169 ms |
14204 KB |
199945 numbers |