You are given an array of numbers.
An operation on the array is defined as :
Select a non-empty subarray of the array and a number . Now flip the -th bit of all the elements of this subarray.
Output the minimum sum of the elements of the given array that can be obtained after doint the above operation at most times.
Input Format
The first line contains two integers and (, ), denoting the number of elements in the array and the maximum number of operations allowed.
The second line contains integers (), the elements of the array.
Output Format
Output the minimum sum of elements that can be obtained by applying the operation at most times.
In First operation, select subarray [5, 4, 5] and flip their most significant bit. After this operation, array becomes [1, 0, 1, 1, 5].
In Second operations, select last element as subarray and flip its most significant bit. After this operation, array becomes [1, 0, 1, 1, 1].
This is the best we can do in 2 operations. So, the anser is 4.