Official algorithmic problem description and constraints.
Chef has a wooden branch of length L. Chef also loves triangles, so he'd like to obtain two more branches and arrange them in the shape of a triangle that he can admire forevermore.
Chef set out to the nearby woods, determined to find two appropriate branches.
There were N (N≤1000) branches lying around in the woods, the i-th of which had length Ai. All these lengths were distinct, i.e, no two branches had the same length. Further, none of the lengths exceeded 109.
Shockingly, Chef couldn't take any pair of these branches to form a triangle with his existing branch!
Can you give an example of the lengths of the branches Chef saw?
It can be shown that under the given constraints, a solution always exists.
If there are multiple possible solutions, you may print any of them.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.