Advertisement
lp-gamboa

problema D

Mar 22nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. # Problem D
  2. n = int(input())
  3. inp = input().split(" ")
  4. people = [ int(x) for x in inp ]
  5. inp = input().split(" ")
  6. s, f = int(inp[0]), int(inp[1])
  7. r = f-s#+1 # tamaΓ±o de la ventana
  8. max_s, idx_max = sum( people[i] for i in range(r) ), 0
  9. sum_ac = max_s
  10. for j in range(n):
  11.     # print(sum_ac, idx_max, res)
  12.     sum_ac = sum_ac - people[j] + people[(r+j)%n]
  13.     if sum_ac>=max_s:
  14.         max_s, idx_max = sum_ac, (j+1)%n
  15. res = (n-idx_max+s)%n if (n-idx_max+s)%n else n
  16. print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement