問題一覧 > 通常問題

No.216 FAC

レベル : / AI推定難易度 : 147 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 610
作問者 : kzyKT
お気に入りにしたユーザー ProblemId : 550 / 自分の提出
問題文最終更新日: 2026-06-27 21:32:03
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 106 (順位表) の他の問題:

Problem Statement

$K$ loves participating in programming contests.
Today, he is participating in $FAC(First \ Accept \ Contest)$ again.
$FAC$ is an unusual contest: for each problem, only the first person to solve it gets its score added.
The person with the highest final score takes $1$st place.

$K$ ended up joining the contest a little late.
Some of the problems have already been solved.
$K$ is a pro, so he can solve every problem in an instant.

Print "$YES$" if $K$, having joined late, can take $1$st place, and "$NO$" if he cannot.
Having the same score as the person in $1$st place also counts as $1$st place.
There are $100$ participants in the contest other than $K$.

Input

$N$
$a_0 \ ... \ a_{N-1}$
$b_0 \ ... \ b_{N-1}$

The $1$st line contains the number of problems $N$.
The $2$nd line contains the score of the $i$-th problem, separated by spaces.
The $3$rd line contains the number of the person who solved the $i$-th problem, separated by spaces.
$b_i$ being $0$ means that the problem has not been solved by anyone yet.

All values are given as integers.
$1 \le N \le 100$
$1 \le a_i \le 100$
$0 \le b_i \le 100$

Output

Print "$YES$" if $K$ can take $1$st place, and "$NO$" if he cannot.

Sample

Sample 1
Input
4
1 100 100 100
0 1 2 3
Output
NO

Only a problem worth $1$ point remains.

Sample 2
Input
3
10 20 30
1 0 0
Output
YES

He can get 50 points, so he can take $1$st place.

Sample 3
Input
3
10 20 30
0 0 1
Output
YES

A tie still counts as $1$st place.

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