Submission #755516

#TimeUsernameProblemLanguageResultExecution timeMemory
755516ZephyrOnFireBalloons (CEOI11_bal)C++17
10 / 100
233 ms6512 KiB
#include <vector> #include <iostream> #include <stack> #include <iomanip> using namespace std; struct ustruct { long long x; long double r; }; signed main() { long long n; cin >> n; long long x[n], maxr[n]; for (long long i = 0; i < n; i++) { cin >> x[i] >> maxr[i]; } stack<ustruct> st; // cout<<__cplusplus<<endl; vector<double> ans(n, 0.0); for (long long i = 0; i < n; i++) { if (st.empty()) { st.push({x[i],(long double)maxr[i]}); ans[i] = maxr[i]; } else { while (!st.empty()) { long long 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()) { st.push({x[i], (long double)maxr[i]}); // st.push({x[i], (double)maxr[i]}); ans[i] = st.top().r; break; } } else { // st.push({x[i], (long double)(curr)}); ans[i] = st.top().r; break; } } } } cout << fixed << setprecision(3); for (auto i : ans) { 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...