Logo
(追記) (追記ここまで)

30936번 - Liquid Distribution 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB83443951.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.

제한

예제 입력 1

2 2
1 3
3 1
2 2
1 3

예제 출력 1

Yes

예제 입력 2

2 2
2 2
2 2
1 3
3 1

예제 출력 2

No

예제 입력 3

3 5
2 5 8
3 5 7
3 3 3 3 3
3 3 3 3 3

예제 출력 3

Yes

예제 입력 4

3 2
4 4 4
1 9 5
6 6
2 13

예제 출력 4

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번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /