Submission #972625

#TimeUsernameProblemLanguageResultExecution timeMemory
972625iag99Balloons (CEOI11_bal)C++17
100 / 100
146 ms7140 KiB
#include <bits/stdc++.h> #define long long long using namespace std; double calcr(pair<double,double> pr, double xc) { return (pr.first-xc)*(pr.first-xc)/(4*pr.second); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n; stack<pair<double,double>> st; vector<double> ans(n); for(int i=0; i<n; i++) { double x,r; cin>>x>>r; double max_r=r; while(!st.empty()) { pair<double,double> prev=st.top(); double new_r=calcr(prev,x); max_r=min(new_r,max_r); if(max_r>=prev.second) { st.pop(); continue; } else { break; } } st.push({x, max_r}); ans[i]=max_r; } cout<<fixed<<setprecision(3); for (double &r : ans) { cout << r << "\n"; } return 0; }
#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...