시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 70 | 29 | 28 | 49.123% |
N people came to some bank to get their salary of a1, a2, . . . , aN tenge. There are total M banknotes left in the bank with values b1, b2, . . . , bM tenge correspondently.
You need to determine whether bank is able to give exact salary to all people using given banknotes or not.
First line of input file contains two integers N and M — number of people and number of banknotes. Second line contains N integers a1, a2, . . . , aN (1 ≤ ai ≤ 1000) — salary values. Third line contains M integer numbers b1, b2, . . . , bM (1 ≤ bi ≤ 1000) — values of banknotes .
The output file must contain one word «YES», if bank is able to pay salary. In opposite case output «NO».
번호 | 배점 | 제한 |
---|---|---|
1 | 19 | N = 1, 1 ≤ M ≤ 20 |
2 | 25 | 1 ≤ N, M ≤ 10 |
3 | 27 | 1 ≤ N ≤ 20, 1 ≤ M ≤ 14 |
4 | 29 | 1 ≤ N, M ≤ 20 |
1 5 8 4 2 5 1 3
YES
2 6 9 10 5 4 8 6 3 11
NO
Olympiad > International Zhautykov Olympiad > IZhO 2014 B번