#P1725. 琪露诺

    ID: 688 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划,dp单调队列优先队列

琪露诺

Description

In Gensokyo, Cirno is an ice fairy known for being a fool.

One day, Cirno was once again playing at flash-freezing frogs, instantly freezing them with ice. But this frog was much smarter than usual and had already run to the other side of the river before Cirno arrived. So Cirno decided to go to the riverbank to chase the frog.

The small river can be viewed as a sequence of cells numbered from 00 to NN. Cirno can only move from a cell with a smaller index to one with a larger index. Moreover, she moves in a special way: when she is on cell ii, she only moves to any cell in the interval [i+L,i+R][i+L, i+R]. Why does she move like this? Simple, because she is a fool.

Each cell has a freeze index AiA_i, and the cell with index 00 has a freeze index of 00. When Cirno stays on a cell, she gains that cell’s freeze index AiA_i. Cirno hopes that by the time she reaches the opposite bank, she will have gained the maximum possible freeze index, so she can teach that frog a good lesson.

However, since she is really too foolish, she asks you to help her decide how to move.

At the beginning, Cirno is on cell 00. As long as the index of her next position is greater than NN, she is considered to have reached the opposite bank.

Input Format

The first line contains three positive integers N,L,RN, L, R.

The second line contains N+1N+1 integers. The ii-th number represents the freeze index Ai1A_{i-1} of the cell with index i1i-1.

Output Format

Output a single integer, the maximum freeze index.

5 2 3
0 12 3 11 7 -2

11


Hint

For 60%60\% of the testdata, N104N \le 10^4.

For 100%100\% of the testdata, N2×105N \le 2\times 10^5, 103Ai103-10^3 \le A_i \le 10^3, 1LRN1 \le L \le R \le N. The testdata guarantees that the final answer does not exceed 23112^{31}-1.

Translated by ChatGPT 5