Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- cash = [int(i) for i in input().split()]
- miss = [int(i) for i in input().split()]
- pr = 0
- maxx = 0
- m = 0
- pref = [0]
- summ = 0
- for i in range(n):
- summ += cash[i]
- pref.append(summ)
- for i in range(len(miss)):
- if i + miss[i] <= n - 1:
- pr = pref[i+miss[i]+1]-pref[i] #sum(cash[i:i + miss[i]])
- if pr > maxx:
- maxx = pr
- m = i
- elif pr == maxx:
- m = max(i, m)
- else:
- pr = pref[n]-pref[i]#sum(cash[i:])
- if pr > maxx:
- maxx = pr
- elif pr == maxx:
- m = max(i, m)
- pr = 0
- print(maxx, m)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement