#C11432. Minimum Shelf Width and Height Difference

    ID: 40748 Type: Default 1000ms 256MiB

Minimum Shelf Width and Height Difference

Minimum Shelf Width and Height Difference

You are given N books, where each book is characterized by its width and height. Your task is to determine two values:

  • The total width of the shelf, which is the sum of the widths of all books.
  • The height difference between the tallest and the shortest book on the shelf.

Note that all books must be placed on the shelf. The answer is a pair of integers representing the total width and the difference between the maximum and minimum book heights.

The formula for the height difference is given in LaTeX as:

$$\text{Height Difference} = \max_{1 \le i \le N} h_i - \min_{1 \le i \le N} h_i$$

where \(h_i\) is the height of the \(i^{th}\) book.

inputFormat

The first line contains an integer N, representing the number of books.

The following N lines each contain two integers separated by space: the width and the height of a book.

outputFormat

Output two space-separated integers on a single line: the total width of the shelf and the height difference between the tallest and the shortest book.

## sample
3
5 8
3 7
6 9
14 2

</p>