CF294B Shaass and Bookshelf
Description
Shaass has $ n $ books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the $ i $ -th book is $ t_{i} $ and its pages' width is equal to $ w_{i} $ . The thickness of each book is either $ 1 $ or $ 2 $ . All books have the same page heights.
Shaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure.
Help Shaass to find the minimum total thickness of the vertical books that we can achieve.
Input Format
N/A
Output Format
N/A