Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Problem D
- n = int(input())
- inp = input().split(" ")
- people = [ int(x) for x in inp ]
- inp = input().split(" ")
- s, f = int(inp[0]), int(inp[1])
- r = f-s#+1 # tamaño de la ventana
- max_s, idx_max = sum( people[i] for i in range(r) ), 0
- sum_ac = max_s
- res = (n-idx_max+s)%n if (n-idx_max+s)%n else n
- for j in range(n):
- # print(sum_ac, idx_max, res)
- sum_ac = sum_ac - people[j] + people[(r+j)%n]
- if sum_ac>max_s:
- max_s, idx_max = sum_ac, (j+1)%n
- res = (n-(j+1)+s)%n if (n-(j+1)+s)%n else n
- elif sum_ac==max_s:
- res_1 = (n-(j+1)+s)%n if (n-(j+1)+s)%n else n
- if res_1<res:
- res=res_1
- # res = (n-idx_max+s)%n if (n-idx_max+s)%n else n
- print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement