Submission #607456

#TimeUsernameProblemLanguageResultExecution timeMemory
607456TH666Balloons (CEOI11_bal)C++17
100 / 100
152 ms12144 KiB
#include <bits/stdc++.h> #define int long long using namespace std; // #define MultipleCase void Solve(int tc) { int n; cin >> n; vector<pair<int,int>> vp(n); for (auto &[x, y] : vp) { cin >> x >> y; } vector<long double> ans(n); stack<pair<int, long double>> s; for (int i = 0; i < n; ++i) { auto [vx, vy] = vp[i]; long double r = vy; while (!s.empty()) { auto [xp, rp] = s.top(); long double cur = (long double) ((xp - vx) * (xp - vx)) / (4.0l * rp); r = min(r, cur); if (r >= rp) s.pop(); else break; } ans[i] = r; s.push({vx, r}); } cout << fixed << setprecision(5); for (auto &i : ans) { cout << i << '\n'; } } int32_t main(void) { ios::sync_with_stdio(false); cin.tie(0); int tt = 1, tc = 0; #ifdef MultipleCase cin >> tt; #endif while (tt--) Solve(++tc); return 0; } /* c1 = (x1, r1), c2 = (x2, r) (x1 - x2) ^ 2 + (r1 - r) ^ 2 == (r1 + r) ^ 2 => (x1 - x2) ^ 2 = 4 * r1 * r => r = (x1 - x2) ^ 2 / (4 * r1) */
#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...