407671: GYM102870 A Accordion Artist And Orz Pandas

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

Description

A. Accordion Artist And Orz Pandastime limit per test0.3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Chuan the Country Builder is a famous accordion artist. Now he wants to put a "Make Accordion Great Again" advertisment, in order to get some advantage over his enemy Bai the Sleeper.

There are $$$n$$$ buildings on the 114514th Avenue, the Old York city. The premium alongside the 114514th Avenue is very high so there is no margin between two adjacent buildings. The front view of the $$$i$$$-th building can be approximated with a rectangle with height $$$h_i$$$ and width $$$w_i$$$.

Chuan wants his advertisment to be a great one. More specifically, it must be a rectangle with the height perpendicular to the height of the front view of each building, and the entire advertisment must fit in the union of the front views of the buildings.

An Orz Panda company has made a contract to build the advertisment for Chuan. The company wants the area of the advertisment to be as large as possible, so they can get more money from Chuan. Please calculate the maximum possible area of all great advertisments.

Input

There is only one test case in the input file.

The first line contains an integer $$$n$$$, the number of the buildings.

The $$$i$$$-th of the following $$$n$$$ lines contains two integers $$$h_i$$$, $$$w_i$$$, the height and weight of the $$$i$$$-th building.

It's guaranteed that $$$1 \leq n \leq 10^5$$$, and $$$1 \leq h_i, w_i \leq 10^5$$$.

Output

Output one line containing the maximum area.

ExamplesInput
5
2 1
4 1
3 1
4 1
1 1
Output
9
Input
5
2 1
4 1
3 1
4 1
2 1
Output
10
Note

The great advertisment with maximum area is illustrated in the following figure. The grey area is the front view of the buildings. There is some margin deliberately added around the advertisment, to make the figure clear.

加入题单

上一题 下一题 算法标签: