No.710 Team Battle
Problem Statement
Yukio-kun and Yukime-san have decided to form a team and enter a competitive programming contest.
To prepare for the contest, the two trained desperately and acquired
- the ability to know exactly, the instant they glance at a problem statement, how many seconds each of them needs to solve the problem
- the ability to correctly solve any competitive programming problem within $10^3$ seconds
Now the contest has begun.
The contest the two are participating in this time has $N$ problems.
The moment the contest started, Yukio-kun and Yukime-san glanced at all $N$ problems and determined, for each problem $i$, the time $A_i$ (seconds) Yukio-kun takes to solve it and the time $B_i$ (seconds) Yukime-san takes to solve it.
- The two solve problems in parallel.
- One person does not solve multiple problems in parallel.
- The two do not solve the same problem at the same time.
- Each of them solves the problems assigned to them one after another, with no gaps in between.
Input
$N$ $A_1$ $B_1$ $A_2$ $B_2$ $\vdots$ $A_N$ $B_N$
$1 \le N \le 100$
$1 \le A_i, B_i \le 10^3$
The input consists of integers.
Output
Output the answer on one line.
Sample
Sample 1
Input
3 45 50 20 80 40 15
Output
60
If Yukime-san takes problem 1 and Yukio-kun takes problems 2 and 3, they solve everything in 60 seconds.
Sample 2
Input
5 600 100 700 100 800 100 900 100 1000 100
Output
500
Yukio-kun just sat there, but the team solved everything in 500 seconds.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
しらっ亭
37zigen