Submission #998475

#TimeUsernameProblemLanguageResultExecution timeMemory
998475hippo123Balloons (CEOI11_bal)C++17
10 / 100
505 ms9552 KiB
#include <bits/stdc++.h> using namespace std; #define pr pair<double, double> #define ll long long #define pb push_back #define f first #define s second vector<double> x, r; vector<pr> xr; bool check(double mid, int bb, int be){ bool judge=false; for (int i=bb; i<be; i++){ double rr=(mid+r[xr[i].s])*(mid+r[xr[i].s]); double dist1=(mid-r[xr[i].s])*(mid-r[xr[i].s])+(x[be]-x[xr[i].s])*(x[be]-x[xr[i].s]); if(rr>=dist1){ judge=true; break; } } return judge; } int main(){ int n; cin>>n; x.resize(n); r.resize(n); xr.resize(n); for (int i=0; i<n; i++) { cin>>x[i]>>r[i]; xr[i].f=x[i]+r[i]; xr[i].s=i; } sort(xr.begin(), xr.end()); vector<double> ans(n); for (int i=0; i<n; i++){ if(i==0) { ans[i]=r[i]; continue; } // pr node={x[i]-r[i], 0}; int pos=lower_bound(xr.begin(), xr.begin()+n, node)-xr.begin(); // pos can only be less than or equal to i; if(pos==i) {ans[i]=r[i]; continue;} double lft=0; double rht=r[i]; while(rht-lft>0.00001){ double mid=lft+(rht-lft)/2; if(check(mid, pos, i)) { rht=mid; } else lft=mid; } ans[i]=lft; } cout << fixed <<setprecision(3); for (int i=0; i<n; i++) cout<<ans[i]<<endl; }
#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...