#C9003. Max Tower Height
Max Tower Height
Max Tower Height
You are given n types of blocks. Each block type i is characterized by its height h_i and a limit l_i that indicates the maximum number of blocks of that type available. The blocks are represented as a tuple of three integers: (h_i, l_i, t_i)
, where t_i
is a type identifier (which does not affect the calculation).
Your task is to build a tower using blocks of a single type such that the tower has the maximum possible height. The height of a tower built using blocks of type i is calculated as:
You need to select the block type that yields the maximum height and output that height.
inputFormat
The input is given from stdin and is formatted as follows:
- The first line contains an integer n representing the number of different block types.
- The following n lines each contain three integers
h_i l_i t_i
separated by spaces, representing the height, the maximum count available, and the type identifier of each block.
outputFormat
Output the maximum tower height that can be achieved (printed to stdout).
## sample3
4 5 1
2 3 2
3 4 3
20
</p>