You have sticks of various lengths given in an array A . You can do the following operation upto m times

Operation : Choose any stick and break it into 2 sticks of non zero lengths.The broken sticks are added back to A . How many maximum sticks of desired length you can make

Example

3 (N)

6 6 11. (Array A)

2 (M no of operations)

3 (d desired length)

Output

4

1st operation

If we choose first 6 then (3,3) are added back to array as (3+3=6)

array becomes

3,3,6,11

In second operation if we choose 2nd 6

then array becomes as (3+3=6)

3,3,3,3,11

So frequency of desired length(3) is 4 in our final array in M=2 operations

This is not a question from any ongoing contest

This was asked by Infosys for SES role on campus in my college today

Pls share the approaches

as i could not solve this question in test

I want to upsolve.