Rosetta Problems

Shelving Books on a Bookshelf

https://atcoder.jp/contests/awc0020/tasks/awc0020_e