Sahu_1402's blog

By Sahu_1402, history, 11 months ago, In English

Given an array of n integers and another array of length m of type [li,ri].
You are also given q queries and in each query you will get an index and a value and you will update arr[index] = value, then you need to print the maximum(arr[li] + arr[li+1] + arr[li+2] + .... + arr[ri]) over all 1<=i<=m.

Constraints : 1<=n,m,q<=1e5; -1e9<=arr[i]<=1e9

Eg. — arr = [1,3,-1,2]
brr = [[0,2],[3,3]]
index = 1 , value = -1
arr = [1,-1,-1,2]
sum([0,2]) = -1
sum([3,3]) = 2
max(-1,2) = 2
ans = 2

Full text and comments »

  • Vote: I like it
  • +15
  • Vote: I do not like it