A bakery shop sells the gift boxes that consists of distinct weighted handmade cookies. To increase their sales, they use a different packing strategy. Write a program to find the box number of a cookie whose weight is Wx, when the number of cookies N and weight of each cookie Wi is provided.
The box comprises of three portions: a smaller box in the center, a cookie on the left and a cookie on the right. The weight of cookies present in the box in the center is less than the weight of both left and right cookie. The cookie on the right side of the box is the heaviest as shown below.
The box comprises of three portions: a smaller box in the center, a cookie on the left and a cookie on the right. The weight of cookies present in the box in the center is less than the weight of both left and right cookie. The cookie on the right side of the box is the heaviest as shown below.
The innermost cookie box will be the first box that will be nested inside the second box, which in turn will be nested inside the third box and so on. The first box contains only one cookie.
A box is denoted using the square brackets '[]'
Read the input from STDIN and print the output to STDOUT. Do not print arbitrary strings anywhere in the program, as these contribute to the output and test cases will fail.
The first line of input contains N, the number of cookies to be packed together. The second line of input consists of weight Wi of N cookies with a single white space between them. The third line of input contains the cookie weight Wx for which the box number has to be found out.
First line of output contains the display of cookie box arrangement without spaces as shown below. [C6[C4[C2[C1]C3]C5]C7] where, C1<C2<C3<C4<C5<C6<C7 Second line of output is the box number of the given cookie weight.