SP12368 TAP2012E - Emma s Domino

Description

\[The original version of this problem (in Spanish) can be found at \] The domino effect is a phenomenon that occurs when in a line of

Input Format

Each test case is described using two lines. The first line contains two integer numbers **N** and **H**, indicating respectively the number of pieces in the line (**3 ****1000**) and their height (**1** ****H** ****50**). The second line contains **N-1** integers **D $ _{i} $** , representing the distances between pairs of consecutive domino pieces, in the order given by the line (**1** ****D $ _{i} $ **100** for **i = 1, 2, ..., N-1**). The end of the input is signalled by a line containing two times the number **-1**.************

Output Format

For each test case, you should print a line containing a single integer number, representing the minimum number of pieces that must be moved in order to have the distance between consecutive pieces always lower or equal to **H**. Note that the first and last pieces cannot be moved, and that the relative order between the the pieces cannot be changed. If it is impossible to achieve the desired result, print the number **-1**.