## LCC/Moose '18 Contest 3 J5 - Line Intersections

View as PDF

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Max has just started grade , and he is in his math class, learning equations of lines!

Max defines the slope-intercept form of a line as the equation of the line in the form . Max is given lines in slope-intercept form, each with a distinct and . Max wants to see, at some integer , the maximum possible value out of all the lines. He wants to test all integer values of in the range , and wants the sum of these values.

Not knowing how to do it, he has asked you to do it for him! Help him!

#### Input Specification

The first line will contain the integer  , the number of lines.

The next lines will each contain two integers,  . It is guaranteed both and are distinct.

#### Output Specification

On the first line, output the sum of the maximum possible values for every integer in the range . Note that 64-bit integers may be required to pass. No further constraints.

#### Sample Input 1

3
4 2
-4 -6
0 -2

#### Sample Output 1

20000400000

#### Sample Input 2

2
-1 1000
1 -1000

#### Sample Output 2

4901049000