最大可能的平衡二进制子字符串拆分,最多花费k个

最大可能的平衡二进制子字符串拆分,最多花费k个

The array in the C programming language has a fixed size, which means that once the size is specified, it cannot be changed; you can neither shrink it or extend it.

正如我们所知,数组是一组相同数据类型的元素,它们存储在连续的内存区域中。

Given an array of values v[] and a binary array a[]. The objective is to use as many k coins to divide the binary array as much as is possible while ensuring that each segment has an equal amount of 0s and 1s. i and j are the neighboring indices of the split segment, and the cost of each split is (v[i] - v[j])2.

Problem Statement

实现一个程序,找到最大可能的平衡二进制子字符串分割,最多花费k。

示例示例1

Let the Input array be: a: [1,0,0, 1, 0, 0, 1, 1] The given values be: v: [7, 8, 9, 10, 11, 12,13,14] K: 1 登录后复制