IOI '04 - Athens, Greece
Famous ancient Greek sculptor Phidias is making preparations to build
another marvelous monument. For this purpose he needs rectangular marble
plates of sizes
Recently, Phidias has received a large rectangular marble slab. He wants
to cut the slab to obtain plates of the desired sizes. Any piece of
marble (the slab or the plates cut from it) can be cut either
horizontally or vertically into two rectangular plates with integral
widths and heights, cutting completely through that piece. This is the
only way to cut pieces and pieces cannot be joined together. Since the
marble has a pattern on it, the plates cannot be rotated: if Phidias
cuts a plate of size
As an example, assume that in the figure below the width of the original
slab is
Your task is to write a program that, given the size of the original slab and the desired plate sizes, calculates the minimum total area of the original slab that must be wasted.
Input Specification
The first line of input contains two integers: first
Output Specification
The output should contain one line with a single integer: the minimum total area of the original slab that must be wasted.
Sample Input
21 11
4
10 4
6 2
7 5
15 10
Sample Output
10
Note: in
Comments