#P1485. 火枪打怪

火枪打怪

Description

LXL enters a jungle and finds nn monsters standing in a line in front of him. LXL has a musket to deal with these monsters. He knows that the health of the ii-th monster from left to right is mim_i. Now LXL can shoot some bullets at certain monsters. LXL can control both the number of bullets he fires and the power of each bullet. When a bullet hits the ii-th monster with power pp, besides that monster losing pp health, the monster at position jj to its left (where j<ij < i) also takes splash damage of max(0,p(ij)2)\max(0, p - (i - j)^2) (what a magical bullet). When a monster’s health becomes less than 00, it dies, but its body remains, i.e., the positions of the monsters never change. LXL wants to use exactly kk bullets. Please find the smallest positive integer pp such that LXL can eliminate all monsters by firing kk bullets, each with power pp.

Input Format

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

The second line contains nn positive integers, where the ii-th integer denotes the health mim_i of the ii-th monster from left to right.

Output Format

Output a single integer, the minimal bullet power pp.

3 1
1 4 5

6

Hint

For 30%30\% of the testdata, n300n \leq 300.

For 100%100\% of the testdata, n5×105n \leq 5 \times 10^5, k5×105k \leq 5 \times 10^5, 1mi10101 \leq m_i \leq 10^{10}.

Translated by ChatGPT 5