Defense of a Kingdom | 프로그래밍의 벗 PivotOJ
PivotOJ

Defense of a Kingdom

시간 제한: 3000ms메모리 제한: 256MB출처: NEERC Northern Subregional 2010BOJ 3532
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

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.

[이미지 1]

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

입력

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 a single integer number — the number of cells in the largest rectangle that is not defended by the towers.

예제

예제 1

입력
15 8 3
3 8
11 2
8 6
출력
12
코드를 제출하려면 로그인하세요.