Submission #755493

#TimeUsernameProblemLanguageResultExecution timeMemory
755493ZephyrOnFireBalloons (CEOI11_bal)C++14
10 / 100
227 ms6216 KiB
#include <vector> #include <iostream> #include <stack> #include <iomanip> using namespace std; struct ustruct { int x; long double r; }; signed main() { int n; cin >> n; int x[n], maxr[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> maxr[i]; } stack<ustruct> st; vector<double> ans(n, 0.0); for (int i = 0; i < n; i++) { if (st.empty()) { ustruct a; a.x = x[i]; a.r = double(maxr[i]); st.push(a); ans[i] = a.r; } else { while (!st.empty()) { int prevx = st.top().x; long double prevr = st.top().r; long double curr; long double wantr = ((x[i] - prevx + 0.0) * (x[i] - prevx + 0.0)) / (4 * prevr + 0.0); if (wantr >= maxr[i]) { curr = maxr[i]; } else { curr = wantr; } if (curr >= prevr) { st.pop(); if (st.empty()) { ustruct a; a.x = x[i]; a.r = double(maxr[i]); st.push(a); // st.push({x[i], (double)maxr[i]}); ans[i] = st.top().r; break; } } else { // ustruct a; a.x = x[i]; a.r = double(curr); st.push(a); // st.push({x[i], curr}); ans[i] = st.top().r; break; } } } } // cout << ans.size(); cout<<fixed<< setprecision(3); for (auto i : ans) { cout << i << " "; // cout << i << " "; } }
#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...