Submission #1126231

#TimeUsernameProblemLanguageResultExecution timeMemory
1126231damamilaBalloons (CEOI11_bal)C++20
100 / 100
139 ms8596 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<pair<int, int>> balloons(n); for (int i = 0; i < n; i++) { int x, r; cin >> x >> r; balloons[i] = {x, r}; } stack<pair<int, double>> s; vector<double> ans(n); for (int i = 0; i < n; i++) { double maxr = balloons[i].second; int bx = balloons[i].first; while (s.size()) { auto [ax, ar] = s.top(); double br = ((bx-ax)*(bx-ax))/(4*ar); maxr = min(maxr, br); if (maxr > ar) { s.pop(); } else { break; } } s.push({bx, maxr}); ans[i] = maxr; } cout << fixed << setprecision(6); for (double i : ans) cout << i << " "; cout << endl; }
#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...