#P1485. 火枪打怪
火枪打怪
Description
LXL enters a jungle and finds 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 -th monster from left to right is . 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 -th monster with power , besides that monster losing health, the monster at position to its left (where ) also takes splash damage of (what a magical bullet). When a monster’s health becomes less than , it dies, but its body remains, i.e., the positions of the monsters never change. LXL wants to use exactly bullets. Please find the smallest positive integer such that LXL can eliminate all monsters by firing bullets, each with power .
Input Format
The first line contains two positive integers .
The second line contains positive integers, where the -th integer denotes the health of the -th monster from left to right.
Output Format
Output a single integer, the minimal bullet power .
3 1
1 4 5
6
Hint
For of the testdata, .
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号