#P3646. [APIO2015] 巴厘岛的雕塑

    ID: 1436 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划,dp贪心2015APIO枚举,暴力进制位运算,按位

[APIO2015] 巴厘岛的雕塑

Description

There are many sculptures along the highways of Bali, Indonesia; we focus on one main road.

There are NN sculptures on this road. For convenience, we number them continuously from 11 to NN, and the age of the ii-th sculpture is YiY_i years. To make the environment of this road more beautiful, the government wants to divide these sculptures into several groups and plant some trees between groups to attract more tourists to Bali.

The rules for grouping the sculptures are as follows:

The sculptures must be divided into exactly XX groups, where AXBA \leq X \leq B. Each group must contain at least one sculpture, and each sculpture must belong to exactly one group. All sculptures within the same group must occupy a contiguous segment along the road.

After the sculptures are grouped, for each group we first compute the sum of ages of all sculptures in that group.

Then we compute the bitwise OR of all these sums. We call this value the final aesthetic value of the grouping.

What is the minimum possible final aesthetic value the government can obtain?

Note: The bitwise OR of two nonnegative numbers PP and QQ is computed as follows:

First convert PP and QQ to binary.

Let nPn_P be the number of binary digits of PP, nQn_Q be that of QQ, and MM be the maximum of nPn_P and nQn_Q. The binary representation of PP is pM1pM2p1p0p_{M-1}p_{M-2} \dots p_1p_0, and that of QQ is qM1qM2q1q0q_{M-1}q_{M-2} \dots q_1 q_0, where pip_i and qiq_i are the ii-th bits in the binary representations of PP and QQ, respectively. The (M1)(M - 1)-th bit is the most significant bit, and the 00-th bit is the least significant bit.

The result of bitwise OR of PP and QQ is: $(p_{M-1}\mathbin{\mathrm{OR}} q_{M-1})(p_{M-2}\mathbin{\mathrm{OR}}q_{M-2})\dots (p_1\mathbin{\mathrm{OR}} q_1) (p_0\mathbin{\mathrm{OR}}q_0)$. Where: 0OR0=00 \mathbin{\mathrm{OR}} 0 = 0

0OR1=10 \mathbin{\mathrm{OR}} 1 = 1

1OR0=11 \mathbin{\mathrm{OR}} 0 = 1

1OR1=11 \mathbin{\mathrm{OR}} 1 = 1.

Input Format

The first line contains three integers N,A,BN, A, B separated by spaces.

The second line contains NN integers Y1,Y2,,YNY_1, Y_2, \dots, Y_N separated by spaces.

Output Format

Output a single line with one number, the minimum possible final aesthetic value.

6 1 3
8 1 2 1 5 4
11

Hint

Sample Explanation:

Divide the sculptures into 22 groups, (8,1,2)(8, 1, 2) and (1,5,4)(1, 5, 4). Their sums are (11)(11) and (10)(10), and the final aesthetic value is (11OR10)=11(11 \mathbin{\mathrm{OR}} 10) = 11. (It is not hard to verify that this is also the minimum final aesthetic value.)

Constraints:

Subtask 1 (9 points) 1N201 \leq N \leq 20; 1ABN1 \leq A \leq B \leq N; 0Yi10000000000 \leq Y_i \leq 1000000000.

Subtask 2 (16 points) 1N501 \leq N \leq 50; 1ABmin{20,N}1 \leq A \leq B \leq \min\{20, N\}; 0Yi100 \leq Y_i \leq 10.

Subtask 3 (21 points) 1N1001 \leq N \leq 100; A=1A = 1; 1BN1 \leq B \leq N; 0Yi200 \leq Y_i \leq 20.

Subtask 4 (25 points) 1N1001 \leq N \leq 100; 1ABN1 \leq A \leq B \leq N; 0Yi10000000000 \leq Y_i \leq 1000000000.

Subtask 5 (29 points) 1N20001 \leq N \leq 2000; A=1A = 1; 1BN1 \leq B \leq N; 0Yi10000000000 \leq Y_i \leq 1000000000.

Translated by ChatGPT 5