cho.sh
Notes
Loading...

Food Wrap Area

Time limit

2s

Memory limit

128 MB

Problem

N pieces of food are placed on a grid with 2 rows and B columns. Each position is given by a row number, either 1 or 2, and a column number.

To store the food, it must be covered with rectangular sheets of wrap. Each sheet may be stretched to any size, but it must cover an axis-aligned rectangle containing at least one cell. Empty cells may be covered as well.

There are K sheets available. Cover every food cell with at least one sheet and minimize the sum of the sheet areas.

Input

The first line contains N, K, and B separated by spaces. (1 ≤ N ≤ 1,000, 1 ≤ K ≤ N, 1 ≤ B ≤ 15,000,000)

Each of the next N lines contains a food position r, c. Here r is the row number, either 1 or 2, and c is the column number. (1 ≤ c ≤ B)

Output

Print the minimum possible sum of wrap areas needed to cover all food.