#include using namespace std; #define int long long #define d double double leftt = -1000; double bot = -1000; double rightt = 1000; double top = 1000; int n; vector> pos; // x, y vector rad; vector> getpoints() { d tot_x = rightt - leftt; d tot_y = top - bot; return { {leftt + tot_x * 3.0 / 8, bot + tot_y * 3.0 / 8}, // BL {leftt + tot_x * 5.0 / 8, bot + tot_y * 3.0 / 8}, // BR {leftt + tot_x * 3.0 / 8, bot + tot_y * 5.0 / 8}, // TL {leftt + tot_x * 5.0 / 8, bot + tot_y * 5.0 / 8} // TR }; } d getworstdist(d tx, d ty) { d ret = 0; for(int i = 0; i < n; i++) { auto [x, y] = pos[i]; d r = rad[i]; d dx = tx - x; d dy = ty - y; d cur_dist = sqrtl(dx * dx + dy * dy) - r; cur_dist = max(cur_dist, 0); ret = max(cur_dist, ret); } return ret; } void rec() { d best_d = 40000; int best_i = 0; auto pts = getpoints(); for(int i = 0; i < 4; i++) { auto [x, y] = pts[i]; d cur_d = getworstdist(x, y); if(cur_d < best_d) { best_d = cur_d; best_i = i; } } d d_x = (rightt - leftt) * 3.0 / 4 / 2; d d_y = (top - bot) * 3.0 / 4 / 2; auto [new_x, new_y] = pts[best_i]; switch(best_i) { case 0: // BL rightt = new_x + d_x; top = new_y + d_y; break; case 1: // BR leftt = new_x - d_x; top = new_y + d_y; break; case 2: // TL rightt = new_x + d_x; bot = new_y - d_y; break; case 3: // TR leftt = new_x - d_x; bot = new_y - d_y; break; } } void solve() { n; cin >> n; pos = vector>(n); rad = vector(n); for(int i =0 ; i < n; i++) cin >> pos[i].first >> pos[i].second >> rad[i]; for(int i =0 ; i < 200; i++) { // d x = (rightt + leftt) / 2; // d y = (top + bot) / 2; rec(); // cout << x << ' ' << y << " -> " << getworstdist(x, y) << '\n'; } d x = (rightt + leftt) / 2; d y = (top + bot) / 2; cout << getworstdist(x, y) << '\n'; } int32_t main() { ios::sync_with_stdio(false); cout << fixed << setprecision(10); cin.tie(0); solve(); return 0; }