Time limit
1s
Memory limit
256 MB
There are N units, and the current number of soldiers in each unit is given. Soldiers are assigned in order from unit 1 to unit N: all soldiers in one unit come before any soldier in the next unit. Therefore, the unit containing a soldier with a given serial number is determined by the prefix sums of the unit sizes.
As the war continues, the size of a unit may increase or decrease. Whenever a size changes, imagine that all soldiers are assigned again from unit 1 using the current unit sizes.
There are two kinds of commands.
1 i a: Change the size of unit i by a soldiers. If a is positive, soldiers are added; if a is negative, soldiers are removed. The input never makes a unit size negative.2 i: Ask which unit currently contains the soldier whose serial number is i.For every command of type 2, output the number of the unit containing that soldier.
The first line contains the number of units N (1 ≤ N ≤ 500,000).
The second line contains N integers, the initial number of soldiers in each unit. Each value is a positive integer at most 1000.
The third line contains the number of commands M (1 ≤ M ≤ 10,000).
Each of the next M lines contains one command.
For a command 1 i a, a is an integer with 1 ≤ |a| ≤ 3,000. For a command 2 i, i is a positive integer not greater than the current total number of soldiers.
For each command of type 2, print the number of the unit containing the requested soldier, one answer per line.