P26316 [AtCoder] Maximum Sum β
提高
题目描述

Problem Description

There are $ N $ pairs of integers. The $ i $ -th pair of integers is $ (A_i, B_i) $.

Snuke is trying to choose exactly one integer from each pair. What is the maximum possible sum of the $ N $ integers chosen?

Input Format

The input is given from the standard input in the following format:

$ N $ $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ $ : $ $ A_N $ $ B_N $

Output Format

Output the maximum possible sum of the $ N $ integers chosen by Snuke.

Sample Input and Output

Sample Input #1

2
20 19
1 100

Sample Output #1

120

Sample Input #2

3
123456789 987654321
999999999 999999999
1000000000 888888888

Sample Output #2

2987654320

Notes/Hints

Constraints

The input satisfies the following conditions:

  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq A_i, B_i \leq 10^9$
  • All values in the input are integers.

Sample Explanation 1

Choosing $ 20 $ from the first pair and $ 100 $ from the second pair results in a sum of $ 20 + 100 = 120 $, which is the maximum possible sum.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 20 19 1 100
样例输出
120