Submission #738205

#TimeUsernameProblemLanguageResultExecution timeMemory
738205ToxtaqBalloons (CEOI11_bal)C++17
40 / 100
2072 ms4948 KiB
#include<bits/stdc++.h> using namespace std; #define eps 1e-6 int n; vector<double>coor, radii, res; double dist(pair<double, double>p1, pair<double, double>p2){ return sqrt((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second)); } bool check(double mid, int indx){ for(int i = indx - 1;i >= 0;--i){ if(dist({coor[i], res[i]}, {coor[indx], mid}) - (mid + res[i]) < eps){ return true; } } return false; } int main() { cin >> n; coor.resize(n); radii.resize(n); res.resize(n); for(int i = 0;i < n;++i){ cin >> coor[i] >> radii[i]; } res[0] = radii[0]; for(int i = 1;i < n;++i){ double l = 0, r = radii[i]; while(r - l > eps){ double mid = (l + r)/ 2; if(check(mid, i)){ r = mid; } else{ l = mid; } } res[i] = l; } for(double i : res)cout << fixed << setprecision(4) << 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...