Suppose you have been given two arrays of length N ( 1 < N <= 100000), say A[1 .. N] & B[1 .. N], Now you have to output another array, C[1 .. N] such that: C[i] = A[i] + min(C[j] — B[j] * B[i]) for all 0 <= j < i. Note: C[0] = A[0] for example : Suppose A = [3, -1, 4, 5, 10] and B = [2, 5, 1, 9, 1]
Ranges : 0 < N < 100000 -10^9 <= A[i] <= 10^9 0 < B[i] < 10^7