atcoder#ARC073C. [ARC073E] Ball Coloring
[ARC073E] Ball Coloring
Score : points
Problem Statement
There are bags, each containing two white balls. The -th box contains two balls with integers and written on them, respectively.
For each of these bags, you will paint one of the balls red, and paint the other blue.
Afterwards, the balls will be classified according to color.
Then, we will define the following:
- : the maximum integer written on a ball painted in red
- : the minimum integer written on a ball painted in red
- : the maximum integer written on a ball painted in blue
- : the minimum integer written on a ball painted in blue
Find the minimum possible value of .
Constraints
Input
Input is given from Standard Input in the following format:
:
Output
Print the minimum possible value.
3
1 2
3 4
5 6
15
The optimal solution is to paint the balls with , , red, and paint the balls with , , blue.
3
1010 10
1000 1
20 1020
380
2
1 1
1000000000 1000000000
999999998000000001