No.216 FAC
タグ : / 解いたユーザー数 610
作問者 :
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もしくは右上の雲マークをクリックしてアカウントを作成してください。