| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 1024 MB | 83 | 44 | 39 | 51.316% |
After years of space exploration, humans succeeded in bringing back a small amount of sample materials from an asteroid to Earth! The materials were stored in several bottles, each containing a complete mixture of two liquids, A and B.
Intense discussion finally reached an agreement that all the materials brought back should be distributed to the research institutes participated in the exploration. The amounts of the liquids A and B to be sent were decided depending on the research topics of each of the institutes.
However, after this decision, a problem was found that it is impossible with current human technologies to separate two liquids from the mixture. The only operations we can perform are to take some amounts of the mixtures from one or more bottles and put them together in a new bottle.
Your task is to judge whether the agreed distribution of the liquids is possible ever.
The input consists of a single test case of the following format.
$n$ $m$
$a_1$ $\cdots$ $a_n$
$b_1$ $\cdots$ $b_n$
$c_1$ $\cdots$ $c_n$
$d_1$ $\cdots$ $d_n$
Here, $n$ is the number of the bottles initially containing the mixtures of liquid A and liquid B, while $m$ is the number of the research institutes to which liquids are to be sent. Both $n$ and $m$ are positive integers not greater than 500ドル$. The following two lines contain $n$ integers each, meaning that the $i$-th bottle (1ドル ≤ i ≤ n$) initially contains the mixture of $a_i$ mL of liquid A and $b_i$ mL of liquid B. The following two lines contain $m$ integers each, meaning that a bottle containing $c_j$ mL of liquid A and $d_j$ mL of liquid B is to be sent to the $j$-th institute (1ドル ≤ j ≤ m$). All of $a_i,ドル $b_i,ドル $c_j$ and $d_j$ are positive integers not greater than 10ドル^6$. Both $\sum_{i=1}^{n}{a_i} = \sum_{j=1}^{m}{c_j}$ and $\sum_{i=1}^{n}{b_i} = \sum_{j=1}^{m}{d_j}$ hold.
If the agreed distribution is possible, output Yes; otherwise, output No in a line.
2 2 1 3 3 1 2 2 1 3
Yes
2 2 2 2 2 2 1 3 3 1
No
3 5 2 5 8 3 5 7 3 3 3 3 3 3 3 3 3 3
Yes
3 2 4 4 4 1 9 5 6 6 2 13
No
For Sample Input 1, the only way that conforms to the decision is to send 0ドル.5$ mL from the bottle 1ドル$ and 2ドル.5$ mL from the bottle 2ドル$ put together in a bottle to the institute 1ドル,ドル and a bottle of the rest to the institute 2ドル$.
For Sample Input 2, the distribution agreement cannot be fulfilled.
ICPC > Regionals > Asia Pacific > Japan > ICPC 2023 Asia Yokohama Regional I번