Created
February 15, 2026 05:45
-
-
Save maehrm/16a3b2ed9d6cec70dd595b2041020d1f to your computer and use it in GitHub Desktop.
D - Robot Arms 2 https://atcoder.jp/contests/abc274/tasks/abc274_d
This file contains hidden or 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
| 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