Computer Science, asked by nishigandhachavan28, 9 months ago

given an array of integers, perform atmost K operations so that the sum of elements of final array is minimum. An operation is defined as follows - Consider any 1 element from the array, arr[i]. Replace arr[i] by floor(arr[i]/2). Perform next operations on updated array. The task is to minimize the sum after atmost K operations. Constraints 1 Select 20. Replace it by 10. New array = [10, 7, 5, 4] Operation 2 -> Select 10. Replace it by 5. New array = [5, 7, 5, 4]. Operation 3 -> Select 7. Replace it by 3. New array = [5,3,5,4]. Sum = 17.​

Answers

Answered by laxmi2017ald
0

Answer:

given an array of integers, perform atmost K operations so that the sum of elements of final array is minimum. An operation is defined as follows - Consider any 1 element from the array, arr[i]. Replace arr[i] by floor(arr[i]/2). Perform next operations on updated array. The task is to minimize the sum after atmost K operations. Constraints 1 Select 20. Replace it by 10. New array = [10, 7, 5, 4] Operation 2 -> Select 10. Replace it by 5. New array = [5, 7, 5, 4]. Operation 3 -> Select 7. Replace it by 3. New array = [5,3,5,4]. Sum = 17.

Explanation:

given an array of integers, perform atmost K operations so that the sum of elements of final array is minimum. An operation is defined as follows - Consider any 1 element from the array, arr[i]. Replace arr[i] by floor(arr[i]/2). Perform next operations on updated array. The task is to minimize the sum after atmost K operations. Constraints 1 Select 20. Replace it by 10. New array = [10, 7, 5, 4] Operation 2 -> Select 10. Replace it by 5. New array = [5, 7, 5, 4]. Operation 3 -> Select 7. Replace it by 3. New array = [5,3,5,4]. Sum = 17.

Similar questions