logo AlgoBeat OnlineJudge
登录 注册

#216165. [ICPC 2024 NAC] Arrested Development

内存限制:2048 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are now in charge of two programming interns, and you must develop a large system. There are a number of tasks that need to be completed by the end of the summer. You know how long each intern will take to complete each task, in minutes.

Compute the minimum number of minutes it will take to complete all tasks for development of the system, assuming that the two interns are the only developers, that they work independently and concurrently, that they do not share tasks, and that the amount of time it takes an intern to complete all their tasks is the sum of the number of minutes it takes to do each task one after the other.

输入格式

The first line of input contains a single integer (), which is the number of tasks.

Each of the next lines contains two integers and (). Each line represents a single task, where is the number of minutes it will take the first intern to complete the task, and is the number of minutes it will take the second intern to complete the task.

输出格式

Output a single integer, which is the minimum number of minutes needed to complete the development project.

样例

样例输入 1

4
100 1
1 90
1 20
1 20

样例输出 1

3

样例输入 2

2
314 1
592 6

样例输出 2

7