#P7371. [COCI 2018/2019 #4] Kisik
[COCI 2018/2019 #4] Kisik
Description
The CAIN organization decided to build a new town on Mars for families, so it will build buildings, one for each family. For each family, CAIN provides different building designs to choose from.
All buildings are placed right next to each other so that their bottoms lie on the same straight line. After construction, the town needs to be inflated and kept inside a glass wall. The glass wall can only enclose a rectangular area, so the inflated region is also a rectangle.
Find the minimum amount of inflation required.
Input Format
The first line contains integers .
The next lines each contain integers , representing the width and height of the -th building. It is guaranteed that there are no duplicate pairs .
Output Format
Output the minimum amount of inflation required.
4 3
2 3
2 2
1 4
3 2
20
3 3
1 1
3 3
2 2
18
4 1
6 4
4 5
19 1
3 6
18
Hint
Explanation of Sample 1
This plan requires only units of inflation, which is the minimum:

Constraints
For the testdata worth points, .
For of the testdata, , .
Notes
The score of this problem follows the original COCI setting, with a full score of .
Translated from COCI2018-2019 CONTEST #4 T3 Kisik.
Translated by ChatGPT 5
京公网安备 11011102002149号