Skip to content

Instantly share code, notes, and snippets.

@maehrm
Created February 15, 2026 05:45
Show Gist options
  • Select an option

  • Save maehrm/16a3b2ed9d6cec70dd595b2041020d1f to your computer and use it in GitHub Desktop.

Select an option

Save maehrm/16a3b2ed9d6cec70dd595b2041020d1f to your computer and use it in GitHub Desktop.
N, x, y = map(int, input().split())
A = list(map(int, input().split()))
x_set = set()
x_set.add(A[0])
for i in range(2, N, 2):
new_set = set()
for p in x_set:
new_set.add(p + A[i])
new_set.add(p - A[i])
x_set = new_set
y_set = set()
y_set.add(0)
for i in range(1, N, 2):
new_set = set()
for p in y_set:
new_set.add(p + A[i])
new_set.add(p - A[i])
y_set = new_set
if x in x_set and y in y_set:
print("Yes")
else:
print("No")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment