Contest.samsu.ru :: соревнования по программированию
Русская версия || English version
Login:
Password:
Забыли пароль?
 пример поиска: Вася Пупкин
 

Задача G для тренировки в сентябре

Первоисточник: ACM ICPC 2010 - 2011, NEERC, Northern Subregional Contest, St Petersburg, October 30, 2010

Задачу добавил: elena

Успешно сдано решений: 5

Problem D. Defense of a Kingdom

Time limit: 3 seconds
Memory limit: 256 megabytes

Theodore implements a new strategy game “Defense of a Kingdom”. On each level player defends the Kingdom that is represented by a rectangular grid of cells. The player builds crossbow towers in some cells of the grid. The tower defends all the cells in the same row and the same column. No two towers share a row or a column.
The penalty of the position is a number of cells in the largest undefended rectangle. For example, the position shown on the picture has penalty 12.



Help Theodore write a program that calculates the penalty of the given position.

Input
The first line of the input file contains three integer numbers: w — width of the grid, h — height of the grid and n — number of crossbow towers (1 ≤ w; h ≤ 40 000; 0 ≤ n ≤ min(w; h)).
Each of the following n lines of the input file contains two integer numbers xi and yi — the coordinates of the cell occupied by a tower (1 ≤ xi ≤ w; 1 ≤ yi ≤ h).

Output
Output a single integer number — the number of cells in the largest rectangle that is not defended by the towers.

Example

input.txt
15 8 3
3 8
11 2
8 6

output.txt
12

Сдать задачу

Задать вопрос жюри по этой задаче