Submission #1300801

#TimeUsernameProblemLanguageResultExecution timeMemory
1300801zowiBalloons (CEOI11_bal)C++20
10 / 100
182 ms6820 KiB
#include <bits/stdc++.h> using namespace std; vector<pair<double,double>> tab; const double eps = 1e-7; bool czy(double a, double r) { double x = tab.back().first - a; double r_prev = tab.back().second; double dy = r - r_prev; double sum = r + r_prev; return x*x + dy*dy < sum*sum; // true if intersects } double find_best_radius(double a, double b) { if (tab.empty()) return b; double low = 0.0; double high = b; // max radius does not intersect → return it if (!czy(a, high)) return high; for (int i = 0; i < 60; ++i) { double mid = (low + high) / 2.0; if (czy(a, mid)) high = mid; else low = mid; } return low; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<double> wyn; for (int i = 0; i < n; ++i) { double a, b; cin >> a >> b; double r_final = find_best_radius(a, b); // Pop all previous circles that intersect the new one while (!tab.empty() && czy(a, r_final)) tab.pop_back(); wyn.push_back(r_final); tab.push_back({a, r_final}); } cout << fixed << setprecision(3); for (double v : wyn) cout << v << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...