Advertisement
konchin_shih

1

Aug 6th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. a[n], k
  2. l = r = cur = 0
  3. while r < n:
  4.     if cur == k:
  5.         print(l, r)
  6.         return
  7.     if cur > k:
  8.         cur -= a[l]
  9.         l += 1
  10.     else:
  11.         cur += a[r]
  12.         r += 1
  13. print(-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement