Korobka887

хуйня.py

Apr 21st, 2023 (edited)
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. n, x = map(int, input().split())
  2. a = list(map(int, input().split()))
  3.  
  4. flag = False
  5. k = 1
  6. i = 0
  7. while i < n and not flag:
  8.     summ1 = 0
  9.     summ2 = 0
  10.     k = 1
  11.     j = i
  12.     while j >= 0 and not flag:
  13.         summ1 += a[j] * k
  14.         summ2 += a[j] * k * -1
  15.         flag = True if summ1 == x and k == 1 or summ2 == x and k == -1 else flag
  16.         k *= -1
  17.         j -= 1
  18.     i += 1
  19.  
  20. print("YES" if flag else "NO")
  21.  
Advertisement
Add Comment
Please, Sign In to add comment