#include #include #include using namespace std; double Opt (int X1, int R1, int X2, int R2){ double Xopt; if(X1 < X2){ Xopt = (X1+X2)/2 + (R1 - R2)/2; }else if(X1 > X2){ Xopt = (X1+X2)/2 + (R2 - R1)/2; }else if(X1 == X2){ Xopt = X1; } return Xopt; } int main(){ int N, buff; cin >> N; vector xyz; for(int i = 0; i < N; i++){ cin >> buff; xyz.push_back(buff); cin >> buff; xyz.push_back(buff); cin >> buff; xyz.push_back(buff); } double Xopt, Yopt, Ropt; Xopt = Opt(xyz[0], xyz[2], xyz[3], xyz[5]); Yopt = Opt(xyz[1], xyz[2], xyz[4], xyz[5]); Ropt = 0; for(int i = 2; i < N; i++){ Xopt = Opt(xyz[i*3], xyz[i*3+2], Xopt, Ropt); Yopt = Opt(xyz[i*3+1], xyz[i*3+2],Yopt, Ropt); } double Xd, Yd; if(Xopt > xyz[(N-1)*3]){ Xd = (Xopt - xyz[(N-1)*3] - xyz[(N-1)*3+2]); }else if(Xopt < xyz[(N-1)*3]){ Xd = (Xopt - xyz[(N-1)*3] + xyz[(N-1)*3+2]); }else if(Xopt == xyz[(N-1)*3]){ Xd = 0; } if(Yopt > xyz[(N-1)*3+1]){ Yd = (Yopt - xyz[(N-1)*3+1] - xyz[(N-1)*3+2]); }else if(Yopt < xyz[(N-1)*3+1]){ Yd = (Yopt - xyz[(N-1)*3+1] + xyz[(N-1)*3+2]); }else if(Yopt == xyz[(N-1)*3+1]){ Yd = 0; } double Distance = sqrt(pow(Xd, 2) + pow(Yd, 2)); cout << Distance << endl; // for(auto n:xyz) cout << n; }