You are given an array \(A\) of \(N\) integers \((A_0,A_1,A_2,....,A_{n-1})\). You have to perform \(Q\) queries of two types :
You are give integer \(T\) for each query \(1\) is for update and \(2\) is for query .
- Update : given three integers \(i,x,s\). Add \(x\) to \(A[i]\) and decrease all the other elements of \(A\) by \(s\) .
- Query : given an integer \(y\) find the value of \(A[y]\).
Note : Here we followed 0-based indexing
Input Format
The first line contains one integer \(N\) — the number of elements in the array.
The second line contains \(N\) integers \(A_0,A_1,A_2,...,A_{n-1}\) .
The next line contains one integer \(Q\) — the number of queries to process.
In each query you are given integer \(T\) .
If \(T = 1\) you are given three integers \(i,x\) and \(s\)
If \(T = 2\) you are given one integer \(y\)
Output Format
For each query of type \(2\), print one integer — \(A[y]\) ( 0-based indexing ).
Constraints :
In the beginning array is [ 3 , 3 , 3 ]
first query is of type 2 . so you print a[1] = 3 .
second query is of type 1. so resultant array is [ -2 , 6 , -2 ]
third query is of type 1 . so resultant array is [ -4 , 7 , -4 ]
fourth query is of type 2 . so you print a[2] = -4.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor