This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
n,m=map(int,input().split())
salaries = list(map(int, input().split()))
banknotes = list(map(int, input().split()))
for salary in salaries:
dp=[False]*(salary+1)
dp[0]=True
for banknote in banknotes:
for i in range(salary,banknote-1,-1):
dp[i]=dp[i]-dp[i-banknote]
if not dp[salary]:
print("NO")
exit()
print("YES")
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |