#d1504. 数组划分

数组划分

Array Partition

Problem Description

Given nn integers, partition them into exactly kk subarrays. Find the maximum possible value of the bitwise AND of the sums of the subarrays.

Input Format

The first line contains two integers n,kn, k.

Output Format

Output one line containing the maximum possible value of the bitwise AND of the sums.

Sample Input

3 2
1 2 3

Sample Output

3

Sample Explanation

There are only two cases:

  1. [1,2],[3][1,2],[3]: the answer is (1+2) & 3=3(1+2)\ \&\ 3 = 3.
  2. [1],[2,3][1],[2,3]: the answer is 1 & (2+3)=11\ \&\ (2+3) = 1.

Thus the answer is 33.

Constraints

For 100%100\% of the data, 1≤k≤n≤1001 \le k \le n \le 100 and 0≤ai≤2500 \le a_i \le 2^{50}.