/*****from dust I have come, dust I will be*****/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define double long double
#define forn(i,n) for(int i=0;i<n;i++)
int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
int ceil_div(int a, int b) {return a % b == 0 ? a / b : a / b + 1;}
const int MOD = 1000000007;
//const int MOD = 998244353;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
/*
int k = A.order_of_key(p[i].second);
A.erase(A.find_by_order(k));
erase element from pbds multiset
*/
double r(double x1, double r1, double x2) {
x1 = x1 - x2;
x1 = x1 * x1;
x1 = x1 / (4.0 * r1);
return x1;
}
void solve(){
int n; cin >> n;
vector<pair<double, double>>a(n);
for (auto &t : a) cin >> t.first>>t.second;
vector<double>ans;
ans.push_back(a[0].second);
stack<pair<double, double>>stek;
stek.push({a[0].first, a[0].second});
for (int i=1;i<n;i++){
double mn = a[i].second;
while (!stek.empty()){
auto t = stek.top();
mn = min(mn, r(t.first, t.second, a[i].first));
if (t.first + t.second < mn + a[i].first) stek.pop();
else break;
}
ans.push_back(mn);
stek.push({a[i].first, mn});
}
for (auto t : ans){
cout << fixed <<setprecision(3);
cout <<t<<'\n';
}
}
int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1; //cin >>t;
for (int i=1;i<=t;i++){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
10 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
2 numbers |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
30th numbers differ - expected: '5.5990000000', found: '14.9870000000', error = '9.3880000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
1752 KB |
196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
3280 KB |
14197th numbers differ - expected: '2.2500000000', found: '2.3440000000', error = '0.0940000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
87 ms |
5984 KB |
7473rd numbers differ - expected: '0.8570000000', found: '1.1670000000', error = '0.3100000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
96 ms |
7056 KB |
4930th numbers differ - expected: '5.0910000000', found: '7.0710000000', error = '1.9800000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
130 ms |
9936 KB |
1734th numbers differ - expected: '1856.0220000000', found: '1865.0000000000', error = '8.9780000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
158 ms |
12492 KB |
2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000' |
2 |
Halted |
0 ms |
0 KB |
- |