405974: GYM102201 B Bohemian Rhaksody

Memory Limit:1024 MB Time Limit:10 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Bohemian Rhaksodytime limit per test10 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputIs this the real life? Is this just fantasy? Caught in a physics formula, no escape from reality...

MolaMola is a world-famous rock band composed of three members: Guitarist Sangsoo cki86201 Park famous for his amazing performance with Link-cut tree, drummer Sunggwan dotorya Park who plays 5 problems in 10 minutes without single WA, and the vocalist Bumsoo zlzmsrhak Park who is responsible for the impressive outlook of the band. The movie about their story, Bohemian Rhaksody, became a blockbuster in Korea, and they are preparing for their perfect comeback concert.

Bumsoo, famous for his unique sense of fashion, thinks that perfect concerts need not only the best music but also great visual effects. Needless to say, the illumination setting is a very important matter for him.

The stage given to them is a $$$H \times W$$$ size rectangle with four corners in $$$(0, 0), (0, W), (H, 0), (H, W)$$$, and there are $$$N$$$ bulbs already installed in the stage. Note that the bulbs may lie on the boundary, but are not strictly outside. To prevent interference, each bulb has a distinct $$$x$$$-coordinate, and each bulb also has a distinct $$$y$$$-coordinate. Every bulb is designed to light either the east/west/south/north part of the stage. More formally, the bulb at the coordinate $$$(X, Y)$$$ can be operated in one of the following modes:

  • Light the area of the stage where $$$x \le X$$$.
  • Light the area of the stage where $$$x \ge X$$$.
  • Light the area of the stage where $$$y \le Y$$$.
  • Light the area of the stage where $$$y \ge Y$$$.

Bumsoo wants their band to play in the brightest area, so the stage will be exactly the area that is lit by all $$$N$$$ bulbs. Now, Bumsoo wants to find a way to operate the bulbs, in order to maximize the area of their stage. Help him!

Input

The first line contains three integers $$$H, W, N$$$. ($$$1 \le N \le 100000, 1 \le H, W \le 10^8$$$)

In the next $$$N$$$ lines, two integers $$$X, Y$$$ are given, indicating that the bulb is installed in coordinate $$$(X, Y)$$$. ($$$0 \le X \le H, 0 \le Y \le W$$$)

It is guaranteed that no pair of different bulbs share an $$$x$$$-coordinate, and no pair of different bulbs share a $$$y$$$-coordinate.

Output

Print the maximum possible area that can be lit by all $$$N$$$ bulbs.

ExamplesInput
4 4 5
0 4
1 3
2 2
3 1
4 0
Output
6
Input
100000000 100000000 1
0 0
Output
10000000000000000
Input
100000000 100000000 12
100000000 59411855
0 4914151
57454627 45388814
93661922 93279520
81531691 0
5221549 64790529
75886863 85609174
74950464 100000000
18493301 57818271
66752434 90450964
44757377 54518291
99631520 21997156
Output
4522156529817280

加入题单

上一题 下一题 算法标签: