This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ld long double
struct P{
ll x, y;
};
void dbg_out() { cerr << endl; }
template <typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }
ld max_r(ll a, ll b, ld R){
return (a-b)*(a-b) / (4*R);
}
signed main(){
fastio;
int n;
cin >> n;
vector<pair<int, ld>> arr (n);
for (int i=0; i<n; i++){
cin >> arr[i].first >> arr[i].second;
}
vector<ld> ans (n);
stack<int> can_touch;
for (int i=0; i<n; i++){
auto [x, r] = arr[i];
ld best=r;
while (!can_touch.empty()){
int X = arr[can_touch.top()].first;
ld R = ans[can_touch.top()];
// touches
if (best >= max_r(x, X, R)) best = max_r(x, X, R);
if (best >= R) can_touch.pop();
else break;
}
ans[i] = best;
can_touch.push(i);
}
cout << fixed << setprecision(3);
for (int i=0; i<n; i++) cout << ans[i] << ' ';
cout << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |