#K71257. Cumulative Sum of Two Lists

    ID: 33491 Type: Default 1000ms 256MiB

Cumulative Sum of Two Lists

Cumulative Sum of Two Lists

You are given two lists A and B each containing N integers. Your task is to compute a new list C such that for every index i (0-indexed),

C[i]=j=0i(A[j]+B[j])C[i] = \sum_{j=0}^{i} \Big(A[j] + B[j]\Big)

In other words, each element C[i] is the cumulative sum of the elements from both lists A and B up to index i.

Example:

Input:
4
1 2 3 4
5 6 7 8

Output: 6 14 24 36

</p>

inputFormat

The first line contains an integer N representing the number of elements in each list. The second line contains N space-separated integers representing the list A. The third line contains N space-separated integers representing the list B.

outputFormat

Output a single line containing N space-separated integers representing the list C, where each C[i] is the cumulative sum defined as

C[i]=j=0i(A[j]+B[j])C[i] = \sum_{j=0}^{i} \Big(A[j] + B[j]\Big)

sample

4
1 2 3 4
5 6 7 8
6 14 24 36