問題一覧 > 通常問題

No.710 Team Battle

レベル : / AI推定難易度 : 1000 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 145
作問者 : しらっ亭 / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 2233 / 自分の提出
問題文最終更新日: 2026-06-25 05:06:06
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 194 (順位表) の他の問題:

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.
Assign the $N$ problems to the two appropriately, and find the minimum number of seconds required to finish solving all the problems.

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もしくは右上の雲マークをクリックしてアカウントを作成してください。