UVA10239 The Book-shelver's Problem

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1180 [PDF](https://uva.onlinejudge.org/external/102/p10239.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10239/ece02ce914a9e758ef51cc35a89cd62fab7af6a1.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10239/fe980e0eceaa2b71dee181ee2d0b33aee5794093.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10239/73b4319fdd60a82f471531c5f968c064b0eabe2d.png)