Submission #923720

#TimeUsernameProblemLanguageResultExecution timeMemory
923720vaneaBalloons (CEOI11_bal)C++14
100 / 100
159 ms7524 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; double calc_r(array<double, 2> a, double bx) { return (a[0] - bx) * (a[0] - bx) / (4 * a[1]); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<double> ans(n); stack<array<double, 2>> s; for(int i = 0; i < n; i++) { double x, r; cin >> x >> r; double mx_r = r; while(!s.empty()) { array<double, 2> last = s.top(); double ro_last_r = calc_r(last, x); mx_r = min(mx_r, ro_last_r); if(mx_r >= last[1]) { s.pop(); continue; } else break; } s.push({x, mx_r}); ans[i] = mx_r; } cout << fixed << setprecision(5); for(auto it : ans) cout << it << ' '; }
#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...