Created
July 26, 2019 13:19
-
-
Save keddad/0474cd2061e8b15382b3f7f3735e3a71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
with open("input.txt", "r") as inp: | |
with open("output.txt", "w") as out: | |
n, m = map(int, inp.__next__().split()) | |
w = [int(x) for x in inp.__next__().split()] | |
dp = [[0 for _ in range(m + 1)] for _ in range(n + 1)] | |
for i in range(1, n + 1): | |
for j in range(1, m + 1): | |
if j >= w[i - 1]: | |
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + w[i - 1]) | |
else: | |
dp[i][j] = dp[i - 1][j] | |
if dp[i][j] == m: | |
out.write("YES") | |
return | |
out.write("NO") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment