Nailed It!
The maximum possible length of the fence is 2, meaning it consists of 2 planks. The first plank is made from wood of lengths 1 and 4, and the second plank is made from wood of lengths 2 and 3. The height of the fence is 5, and no other heights are possible.
Input Example 2:
5
1 10 100 1000 2000
Output Example 2:
1 10
Explanation for Example 2:
The maximum possible length of the fence is 1, meaning it consists of 1 plank. In this case, any two pieces of wood can form a plank, resulting in 10 different possible heights: 11, 101, 1001, 2001, 110, 1010, 2010, 1100, 2100, 3000.
Comments