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;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll n;
cin >> n;
vector<pll> balloons(n);
for (auto &ref: balloons) cin >> ref.first >> ref.second;
vector<ld> final_inflate(n);
vector<ll> mono_stck;
for (int i = 0; i < n; i++) {
ll curr_x = balloons[i].first;
ll max_r = balloons[i].second;
if (mono_stck.empty()) {
final_inflate[i] = max_r;
} else {
// ll start = 0;
// ll end = mono_stck.size();
// while (start < end) {
// ll third = start + (end - start) / 3;
// ll third2 = start + 2 * (end - start) / 3;
//
//
// }
ld max_radius = max_r;
for (int j = mono_stck.size() - 1; j >= 0; j--) {
max_radius = min(max_radius,
(ld) ((curr_x - balloons[mono_stck[j]].first) *
(curr_x - balloons[mono_stck[j]].first)) /
(ld) (4 * final_inflate[mono_stck[j]])
);
}
final_inflate[i] = max_radius;
}
while (!mono_stck.empty() && final_inflate[mono_stck.back()] <= final_inflate[i])
mono_stck.pop_back();
mono_stck.push_back(i);
}
for (auto final_r: final_inflate) {
cout << fixed << setprecision(4) << final_r << endl;
}
}
# | 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... |