Submission #762061

#TimeUsernameProblemLanguageResultExecution timeMemory
762061Sig0001Balloons (CEOI11_bal)C++17
20 / 100
171 ms11272 KiB
#include <bits/stdc++.h> using namespace std; double maxRadius(int x1, int x2, double r1) { /** * (x2 - x1)^2 + (r2 - r1)^2 = (r2 + r1)^2 * (x2 - x1)^2 = 4 r1 r2 */ return (x2 - x1) * (x2 - x1) / (4 * r1); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<int, double>> a(n); // [x, maxRadius] for (auto &[x, r]: a) cin >> x >> r; vector<double> ans(n); ans[0] = a[0].second; stack<pair<int, double>> st; // [position, radius] cout << fixed << setprecision(3); for (int i = 0; i < n; i++) { auto [x2, maxR2] = a[i]; double r2 = maxR2; while (not st.empty()) { auto [x1, r1] = st.top(); r2 = min(r2, maxRadius(x1, x2, r1)); if (r2 < r1) break; st.pop(); } st.emplace(x2, r2); cout << r2 << '\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...