#include <bits/stdc++.h>
using namespace std;
long double ck(long double posi, long double posj, long double ri){
long double on = ((posj - posi) * (posj - posi));
return (on) / (4.0L * ri);
}
int main() {
int n;
cin >> n;
pair<long double, long double> bal[n];
for (int i = 0; i < n; i++) {
cin >> bal[i].first >> bal[i].second;
}
stack<pair<int, long double>> s;
vector<long double> ans(n);
ans[0] = bal[0].second;
s.push({0, bal[0].second});
for (int i = 1; i < n; i++) {
ans[i] = bal[i].second;
if (!s.empty()) {
pair<int, long double> a = s.top();
while (!s.empty()) {
long double v = ck(bal[a.first].first, bal[i].first, a.second);
ans[i] = min(ans[i], v);
if (v >= ans[a.first]) {
s.pop();
if (!s.empty()) {
a = s.top();
}
}
else {
break;
}
}
}
if (!s.empty()) {
pair<int, long double> a = s.top();
ans[i] = min(ck(bal[a.first].first, bal[i].first, a.second), bal[i].second);
}
s.push({i, ans[i]});
}
for (auto x : ans) {
cout << fixed << setprecision(3) << x << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
14th numbers differ - expected: '2.6090000000', found: '7.1410000000', error = '4.5320000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
348 KB |
504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
1324 KB |
653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
3096 KB |
14171st numbers differ - expected: '0.7300000000', found: '0.7430000000', error = '0.0130000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
119 ms |
5972 KB |
7445th numbers differ - expected: '0.7860000000', found: '0.8060000000', error = '0.0200000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
6848 KB |
4791st numbers differ - expected: '0.8470000000', found: '0.8730000000', error = '0.0260000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
192 ms |
9084 KB |
1732nd numbers differ - expected: '2.0480000000', found: '2.8120000000', error = '0.7640000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
240 ms |
11348 KB |
2732nd numbers differ - expected: '2.5370000000', found: '2.7380000000', error = '0.2010000000' |
2 |
Halted |
0 ms |
0 KB |
- |