#P2160. [SHOI2007] 书柜的尺寸

    ID: 1138 远端评测题 5000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp数学2007各省省选上海排序

[SHOI2007] 书柜的尺寸

Description

Tom does not like those long, single-row bookshelves. He only wants a small bookcase to store his series of reference books. Tom plans to place the bookcase behind his desk so he does not need to stand up to look things up.

Obviously, this bookcase cannot be too large. Tom wants its volume to be as small as possible. Also, for aesthetic reasons, he wants a three-tier bookcase. To make full use of the space, Tom requires that each tier must contain at least one book. Now the question is: how should Tom distribute his reference books so that the carpenter can build the smallest possible bookcase?

Tom quickly realized that this is a math problem. Each book has its own height hih_i and thickness tit_i. What we need is an assignment plan, meaning we must assign every book to exactly one of S1S_1, S2S_2, and S3S_3 — the three non-empty sets — with no duplication and no omission. Then, it is clear that the front surface area of the bookcase (SS) is given by:

$$S=\left(\sum_{j=1}^3 \max_{i \in S_j} h_i\right) \times \left(\max_{j=1}^3 \sum_{i \in S_j} t_i\right)$$

Since the depth of the bookcase is fixed (obviously, it should equal the length of the widest book), minimizing the volume of the bookcase is equivalent to minimizing SS. Tom is just one step away from the answer. Unfortunately, Tom is not good at programming, so he invites you to help him solve this problem.

Input Format

The first line contains an integer nn, the number of books.

Each of the next nn lines contains two integers hih_i and tit_i, representing the height and thickness of each book.

Output Format

Output a single line: the minimal SS.

4
220 29
195 20
200 9
180 30
18000

Hint

Constraints: for all testdata, 3n703 \leq n \leq 70, 150hi300150 \leq h_i \leq 300, 5ti305 \leq t_i \leq 30.

Translated by ChatGPT 5