

Time Limit: 5 sec / Memory Limit: 1024 MB
配点 : 点
問題文
数列 , があります。これらに対して、以下の 種類の操作を、任意の順番で任意の回数だけ行うことができます。
- を満たす を選び、 を任意の非負整数に置き換える。
- を満たす を選び、 を任意の非負整数に置き換える。
- 数列 の要素を任意の順番に並び替える。
操作の結果、, の全ての要素が非負であり、なおかつ となるようにできるかを判定してください。
制約
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
出力
操作の結果、, の全ての要素が非負かつ となるようにできる場合は Yes
、そうでない場合は No
を出力せよ。
入力例 1Copy
4 2 0 -1 3 3 -1 4 2
出力例 1Copy
Yes
以下の操作を行うことを考えます。
- を に置き換える。
- を に置き換える。
- を並び替えて にする。
操作の結果、, となり、, の全ての要素が非負かつ が満たされます。
入力例 2Copy
3 1 2 3 1 2 4
出力例 2Copy
No
どのように操作を行っても、 を満たすようにはできません。
入力例 3Copy
3 1 2 -1 1 2 4
出力例 3Copy
No
Score : points
Problem Statement
There are two sequences and . You can perform the following three types of operations any number of times in any order:
- Choose an index such that , and replace with any non-negative integer.
- Choose an index such that , and replace with any non-negative integer.
- Rearrange the elements of sequence in any order.
Determine whether it is possible, after these operations, for all elements of and to be non-negative and satisfy .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
If it is possible, after the operations, for all elements of and to be non-negative and satisfy , print Yes
. Otherwise, print No
.
Sample Input 1Copy
4 2 0 -1 3 3 -1 4 2
Sample Output 1Copy
Yes
Consider the following operations:
- Replace with .
- Replace with .
- Rearrange to .
After these operations, and : all elements of and are non-negative, and is satisfied.
Sample Input 2Copy
3 1 2 3 1 2 4
Sample Output 2Copy
No
No matter how you perform the operations, it is impossible to satisfy .
Sample Input 3Copy
3 1 2 -1 1 2 4
Sample Output 3Copy
No