I was able to solve first one which was variant of "Allocate minimum number of pages/ painters partition problem". I have no idea how to solve this one, any help will be appreciated. Thanks!