Can you make change?
Statement
Goal
During lunch break at your school, one of your friends asks you if you can exchange his K dollar bill to lower value bills.You have an unlimited number of bills of N distinct values.
Can you exchange your friends money?
Example: Your friend wants change for 50 dollars and you have an unlimited number of 5 dollar bills, so you offer him 10 5 dollar bills in return.
Input
Line 1: K value of your friend's bill.
Line 2: N different types of bills you have at your disposal.
Line 3: N numbers representing the values of your bills.
Line 2: N different types of bills you have at your disposal.
Line 3: N numbers representing the values of your bills.
Output
Line 1: "Yes" if you are able to exchange the money or "No" if you are unable to exchange his money.
Constraints
5 ≤ K ≤ 1000
1 ≤ N ≤ 10
1 ≤ value of your bills < K
1 ≤ N ≤ 10
1 ≤ value of your bills < K
Example
Input
50 2 2 5
Output
Yes
Game modes
Fastest, Shortest
Test cases
Test 1 Test
Input
50
2
2 5
Output
Yes
Validator 1 Validator
Input
50
5
9 8 7 6 3
Output
Yes
Test 2 Test
Input
250
1
100
Output
No
Validator 2 Validator
Input
300
1
10
Output
Yes
Test 3 Test
Input
25
2
2 3
Output
Yes
Validator 3 Validator
Input
25
2
10 6
Output
No
Test 4 Test
Input
1000
10
7 4 3 50 60 5 19 64 54 23
Output
Yes
Validator 4 Validator
Input
1000
10
7 4 3 51 61 6 19 64 54 23
Output
Yes
Test 5 Test
Input
525
3
2 3 50
Output
Yes
Validator 5 Validator
Input
525
3
2 4 12
Output
No
Test 6 Test
Input
1000
1
1
Output
Yes
Validator 6 Validator
Input
999
1
1
Output
Yes
Test 7 Test
Input
81
3
2 10 12
Output
No
Validator 7 Validator
Input
81
3
4 10 12
Output
No
Test 8 Test
Input
185
2
75 40
Output
No
Validator 8 Validator
Input
185
2
70 40
Output
No
Solution language
Solution
Stub generator input