Submission #941154

#TimeUsernameProblemLanguageResultExecution timeMemory
941154agawronBalloons (CEOI11_bal)C++14
30 / 100
110 ms4948 KiB
#include<bits/stdc++.h> using namespace std; using pdd = pair <double, double>; #define f first #define s second constexpr int MAX_N = 2e5 + 5; double calc_r(pdd last, double cord){ return (last.f - cord) * (last.f - cord)/(4 * last.s); } int n; int x[MAX_N], r[MAX_N]; double ans[MAX_N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 0; i < n; i++){ cin >> x[i] >> r[i]; } stack <pdd> st; for(int i = 0; i < n; i++){ double max_r = r[i]; while(st.size() > 0){ pdd last = st.top(); double to_last = calc_r(last, x[i]); max_r = min(max_r, to_last); if(last.s > to_last) break; else st.pop(); } st.push({x[i], max_r}); ans[i] = max_r; } cout << fixed << setprecision(3); for(int i = 0; i < n; i++){ cout << ans[i] << '\n'; } }
#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...