Блог пользователя sreyan32

Автор sreyan32, история, 3 года назад, По-английски

Hi,

I need some help in the following problem.

Given a circular buffer of integers (positive/negative), what is the minimum number of conversions (addition/subtraction by 1) on elements so that all K subarrays have the same sum. The cost of each conversion is 1.

Constraints:

  1. The input array represents a circular array.
  2. The numbers in the array can be positive or negative integers.

Example:

N = 10 (size of the array)
K = 1 (size of the subarrays)
array = [1,2,3,4,5,6,7,8,9,10]

Output is 25 (changing all the values to 5 satisfies the constraints)
  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится