Help in Educational Codeforces Round 82

Problem - Problem - D - Codeforces
My solution -Submission #75076146 - Codeforces

First I stored all the bits in an array , then iterate from LSB to MSB , and if the i-th bit is not set in n , I simply add all the bits in the i-th position in the array and take the result to next element.
If the i-th bit is set in n , then if i-th position of the array has non - zero value, I leave one bit and add the rest for the next element , else I iterate toward MSB from that position till the nearest non-zero value of array the from there I iterate back to the i-th bit dividing the values ( for example if the values 100 in binary , I make it into two 10 and store as 2,0 as there are 10 and 10 )

I am getting WA on 3rd test case , any help would be appreciated . Thanks in advance .


932 8
16384 128 256 256 1 2 2048 4096 

your code gives 7, whereas a randomly selected AC code gives 8.

1 Like

thanks. found the mistake in my code .