CF294B.Shaass and Bookshelf
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
Shaass 有 n 本书。他想为所有这些书制作一个书架,且希望书架的尺寸尽可能小。第 i 本书的厚度为 ti,其页面的宽度为 wi。每本书的厚度均为 1 或 2。所有书的页面高度均相同。

Shaass 按如下方式将书摆放在书架上:首先,他选出其中一部分书竖直放置;然后,将剩余的书水平放置在竖直摆放的书的上方。所有水平摆放的书的宽度之和不得超过竖直摆放的书的总厚度。图中展示了一种书籍摆放的示例。

请帮助 Shaass 找出所能达到的竖直摆放书籍的最小总厚度。
输入格式
The first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t__i and w__i denoting the thickness and width of the i-th book correspondingly, (1 ≤ t__i ≤ 2, 1 ≤ w__i ≤ 100).
输入的第一行包含一个整数 n(1 ≤ n ≤ 100)。接下来的 n 行中,每行包含两个整数 ti 和 wi,分别表示第 i 本书的厚度和宽度(1 ≤ ti ≤ 2,1 ≤ wi ≤ 100)。
输出格式
On the only line of the output print the minimum total thickness of the vertical books that we can achieve.
在输出的唯一一行中,打印我们能够达到的竖放书籍的最小总厚度。
输入输出样例
输入#1
5 1 12 1 3 2 15 2 5 2 1
输出#1
5
输入#2
3 1 10 2 1 2 4
输出#2
3
输入解题思路,AI测评打分。不知道怎么写?