[BOJ 11855] Bank

View as PDF

Submit solution

Points: 4
Time limit: 1.0s
Memory limit: 256M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

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.</p>

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

1 5
8
4 2 5 1 3

예제 출력 1

YES

예제 입력 2

2 6
9 10
5 4 8 6 3 11

예제 출력 2

NO

Comments

There are no comments at the moment.