問題一覧 > 通常問題

No.1570 Blocks

レベル : / AI推定難易度 : 1125 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 69
作問者 : maguro / テスター : blackyuki PCTprobability
お気に入りにしたユーザー ProblemId : 6281 / 自分の提出
問題文最終更新日: 2021-04-20 21:50:53
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
灘校文化祭コンテスト 2021 day2 (順位表) の他の問題:

Problem Statement

There are $N$ blocks. Block $i\ (1 \leq i \leq N)$ has weight $A_i$ and load capacity $B_i$.

Is it possible to stack all the blocks in $1$ column so that the following condition is satisfied?

  • For every block $i$, the total weight of the blocks stacked above block $i$ does not exceed $B_i$.

Input

$N$
$A_1\ B_1$
$A_2\ B_2$
$\vdots$
$A_N\ B_N$

  • All inputs are integers.
  • $1 \leq N \leq 10^5$
  • $1 \leq A_i,B_i \leq 10^9$

Output

Print Yes if it is possible to stack all the blocks in $1$ column so that the condition is satisfied, and No otherwise. Print a newline at the end.

Sample

Sample 1
Input
4
2 3
2 4
1 5
4 5
Output
Yes

For example, stacking block $1$, block $3$, block $2$, block $4$ in this order from the top satisfies the condition.

Sample 2
Input
3
6 5
4 5
2 2
Output
No

The condition cannot be satisfied no matter how the blocks are stacked.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。