Editorial for TLE '16 Contest 5 P4 - Engineering Test
                Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
                Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
First, add  to all of the 
. This is the maximum allowed apparent weights of the tables. Next, generate the actual table patterns, which looks like a Pascal's triangle. A table adds half of its weight to the tables below. Make sure to round upwards when calculating the apparent weights.
To check if a certain table height  works, get the numbers in the top 
 rows, and sort these numbers. Afterwards, get the 
 strongest tables. If there are enough tables, and these tables can support the structure, then this value of 
 will work.
Time Complexity: 
Comments