{"raw_statement":[{"iden":"statement","content":"Two neighbours, Alan and Bob, live in the city, where there are three buildings only: a cinema, a shop and the house, where they live. The rest is a big asphalt square.\n\nOnce they went to the cinema, and the film impressed them so deeply, that when they left the cinema, they did not want to stop discussing it.\n\nBob wants to get home, but Alan has to go to the shop first, and only then go home. So, they agreed to cover some distance together discussing the film (their common path might pass through the shop, or they might walk circles around the cinema together), and then to part each other's company and go each his own way. After they part, they will start thinking about their daily pursuits; and even if they meet again, they won't be able to go on with the discussion. Thus, Bob's path will be a continuous curve, having the cinema and the house as its ends. Alan's path — a continuous curve, going through the shop, and having the cinema and the house as its ends.\n\nThe film ended late, that's why the whole distance covered by Alan should not differ from the shortest one by more than _t_1, and the distance covered by Bob should not differ from the shortest one by more than _t_2.\n\nFind the maximum distance that Alan and Bob will cover together, discussing the film."},{"iden":"input","content":"The first line contains two integers: _t_1, _t_2 (0 ≤ _t_1, _t_2 ≤ 100). The second line contains the cinema's coordinates, the third one — the house's, and the last line — the shop's.\n\nAll the coordinates are given in meters, are integer, and do not exceed 100 in absolute magnitude. No two given places are in the same building."},{"iden":"output","content":"In the only line output one number — the maximum distance that Alan and Bob will cover together, discussing the film. Output the answer accurate to not less than 4 decimal places."},{"iden":"examples","content":"Input\n\n0 2\n0 0\n4 0\n-3 0\n\nOutput\n\n1.0000000000\n\nInput\n\n0 0\n0 0\n2 0\n1 0\n\nOutput\n\n2.0000000000"}],"translated_statement":[{"iden":"statement","content":"两位邻居艾伦和鲍勃住在一座只有三座建筑的城市中：一家电影院、一家商店和他们居住的房屋。其余区域是一片巨大的沥青广场。\n\n有一次，他们去看了电影，影片给他们留下了深刻印象，以至于离开电影院后，他们仍不愿停止讨论。\n\n鲍勃想回家，但艾伦必须先去商店，然后再回家。因此，他们达成协议：先一起走一段路讨论电影（他们的共同路径可能经过商店，也可能绕着电影院兜圈子），然后各自分道扬镳，走自己的路。分开后，他们将开始思考各自日常的事情；即使再次相遇，也无法继续讨论。因此，鲍勃的路径是一条连续曲线，起点为电影院，终点为房屋。艾伦的路径是一条连续曲线，必须经过商店，起点为电影院，终点为房屋。\n\n电影结束得较晚，因此艾伦所走的总路程与最短路径的差距不得超过 #cf_span[t1]，鲍勃所走的总路程与最短路径的差距不得超过 #cf_span[t2]。\n\n求艾伦和鲍勃一起行走、讨论电影的最大距离。\n\n第一行包含两个整数：#cf_span[t1, t2]（#cf_span[0 ≤ t1, t2 ≤ 100]）。第二行是电影院的坐标，第三行是房屋的坐标，最后一行是商店的坐标。\n\n所有坐标单位为米，均为整数，绝对值不超过 100。任意两个给定地点不在同一栋建筑中。\n\n仅输出一行：艾伦和鲍勃一起行走、讨论电影的最大距离。答案需精确到至少 4 位小数。"},{"iden":"input","content":"第一行包含两个整数：#cf_span[t1, t2]（#cf_span[0 ≤ t1, t2 ≤ 100]）。第二行是电影院的坐标，第三行是房屋的坐标，最后一行是商店的坐标。所有坐标单位为米，均为整数，绝对值不超过 100。任意两个给定地点不在同一栋建筑中。"},{"iden":"output","content":"仅输出一行：艾伦和鲍勃一起行走、讨论电影的最大距离。答案需精确到至少 4 位小数。"},{"iden":"examples","content":"输入\n0 20\n0 0\n4 0\n-3 0\n输出\n1.0000000000\n\n输入\n0 0\n0 0\n2 0\n1 0\n输出\n2.0000000000"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**\nLet the coordinates of the Cinema, House, and Shop be defined as points in a Euclidean plane:\n$C, H, S \\in \\mathbb{R}^2$.\n\nLet $t_1, t_2 \\in \\mathbb{R}_{\\ge 0}$ be the maximum allowable deviations from the shortest path lengths for Alan and Bob, respectively.\n\nLet $d(X, Y) = \\|X - Y\\|_2$ denote the Euclidean distance between points $X$ and $Y$.\n\n**Objective**\nFind the maximum common distance $D_{\\max}$ that Alan and Bob can traverse together. This is the maximum of two sub-problems based on whether the separation point $P$ occurs before or after visiting the Shop.\n\n$$ D_{\\max} = \\max(V_1, V_2) $$\n\n**Sub-problem 1: Separation before or at the Shop**\nMaximize the distance from the Cinema to a split point $P$, such that Alan can proceed to the Shop and then the House, and Bob can proceed directly to the House, within their respective total distance constraints.\n\n$$ V_1 = \\max_{P \\in \\mathbb{R}^2} \\, d(C, P) $$\nSubject to:\n1.  **Bob's Constraint:**\n    $$ d(C, P) + d(P, H) \\le d(C, H) + t_2 $$\n2.  **Alan's Constraint:**\n    $$ (d(C, P) + d(P, S) + d(S, H)) - (d(C, S) + d(S, H)) \\le t_1 $$\n    $$ \\implies d(C, P) + d(P, S) \\le d(C, S) + t_1 $$\n\n**Sub-problem 2: Separation after or at the Shop**\nMaximize the total path length passing through the Shop to a split point $P$, such that both can proceed to the House within constraints.\n\n$$ V_2 = \\max_{P \\in \\mathbb{R}^2} \\, (d(C, S) + d(S, P)) $$\nSubject to:\n1.  **Bob's Constraint:**\n    $$ d(C, S) + d(S, P) + d(P, H) \\le d(C, H) + t_2 $$\n2.  **Alan's Constraint:**\n    $$ (d(C, S) + d(S, P) + d(P, H)) - (d(C, S) + d(S, H)) \\le t_1 $$\n    $$ \\implies d(S, P) + d(P, H) \\le d(S, H) + t_1 $$","simple_statement":null,"has_page_source":false}