{"problem":{"name":"J. Beautiful Triangles","description":{"content":"Sancho loves geometry. And he loves triangles even more, to the point of developing his own metric of beauty for triangles. In his metric, the beauty of a triangle is calculated by subtracting the len","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10148J"},"statements":[{"statement_type":"Markdown","content":"Sancho loves geometry. And he loves triangles even more, to the point of developing his own metric of beauty for triangles. In his metric, the beauty of a triangle is calculated by subtracting the length of the largest side from the sum of the lengths of the other two sides.\n\nDuring weekends, Sancho likes to walk by the beach looking for straight sticks to build his triangles. He has already found 2 sticks and he's very optimistic about the triangle he's going to build. \n\nHe wants to know what should be the length of the third stick so that the beauty of his triangle is maximized. Help him with this task!\n\nThe input consists of a single line, containing two integers l1 and l2 (1 ≤ l1, l2 ≤ 2 × 109) indicating the length of the sticks that Sancho has already found.\n\nOutput a single integer: the length of the third stick that maximizes the beauty of the triangle that Sancho is going to build.\n\n## Input\n\nThe input consists of a single line, containing two integers l1 and l2 (1 ≤ l1, l2 ≤ 2 × 109) indicating the length of the sticks that Sancho has already found.\n\n## Output\n\nOutput a single integer: the length of the third stick that maximizes the beauty of the triangle that Sancho is going to build.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"Let $ l_1, l_2 \\in \\mathbb{Z}^+ $ be the lengths of the two given sticks, with $ 1 \\leq l_1, l_2 \\leq 2 \\times 10^9 $.\n\nLet $ x \\in \\mathbb{R}^+ $ be the length of the third stick.\n\nThe beauty of the triangle is defined as:\n$$\nB(x) = (l_1 + l_2 + x) - 2 \\cdot \\max(l_1, l_2, x)\n$$\n\nSubject to the triangle inequality:\n$$\nx < l_1 + l_2, \\quad l_1 < l_2 + x, \\quad l_2 < l_1 + x\n$$\n\n**Objective**: Find $ x \\in \\mathbb{R}^+ $ that maximizes $ B(x) $, under the triangle inequality constraints.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10148J","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}