Maybe you all are familiar with Jenga Game. "Jenga is played with 54 wooden blocks. Each block is three times as long as it is wide, and one fifth as thick as its length".
Today we are going to play another version of Jenga game. In our game we have two tower made of wooden blocks and they (wooden blocks) are of different heights. These wooden blocks sit on top of another thus creating a tower. Height of a tower is the summation of height of the blocks.
You will be given configurations of two towers (i.e. sequence of wooden blocks for each tower).
You are allowed to remove any amount (possibly 0) of blocks from any configuration.
Your task is to find the minimum number of blocks to be removed from the given two configuration of blocks to make the heights of two tower equal.
The first line of the input consists of an integer value n , 0 < n <= 16 . (n, Number of wooden blocks to create first tower and second tower).
Second line contains n positive integers bi (0 < bi<108). bi is the height of ith block.
Third line contains n positive integers ci (0 < ci<108). ci is the height of ith block.
Print a single integer R which denotes the minimum number of blocks to be removed from the given two configuration of blocks to make the heights of two tower equal.
3 1 5 9 2 6 6
Remove first block of tower one. Optimal result is 1.
Login to submit