There is a paper strip consisting of unit cells numbered from left to right. Boundary lies between cells and and has cost .
Initially all cells form one paper piece. Repeat the following operation:
You must make exactly cuts until every cell is a separate piece.
Find the minimum total cost among cutting orders with exactly red cuts. Print -1 if no such order exists.
The input is given in the following format:
For each test case, print the minimum cost of a cutting order with exactly red cuts. Print -1 if no such order exists.
In the first test case, boundaries and can be made red for a total cost of . In the second test case, at most two red cuts are possible.
Each case is given in the following format:
No additional constraints. |