P5891 Fracture Ray

Background

Broken rays are reflected in a broken mirror; broken words hide something broken—

Description

There is an array `a[]` of type `long long`. Before giving all operations, an upper bound parameter $v$ is given. There are $q$ operations in total. Each operation is one of the following two functions: ``` void modify(int u,int p) { for (int i=u;i

Input Format

Read input from standard input. The first line contains two positive integers $q, v$, representing the number of operations and the upper bound parameter. The next $q$ lines are one of the following: + `1 u p` means executing `modify(u,p)`. + `2 u` means executing `query(u)` and outputting one integer per line, which is the return value of the function.

Output Format

After each execution of `query()`, output the return value of the function.

Explanation/Hint

Subtask 1 ($8$ points): $1\leq q\leq 10^3$, $1\leq v\leq 10^4$. Subtask 2 ($23$ points): $1\leq v\leq 10^5$. Subtask 3 ($16$ points): $1\leq q\leq 50$. Subtask 4 ($28$ points): $1\leq q\leq 1000$. Subtask 5 ($25$ points): no special restrictions. For all data, $1\leq q\leq 2\times 10^5$, $1\leq u\leq v< 2^{30}$, $-10^4\leq p\leq 10^4$. Please pay attention to the impact of constant factors on program efficiency when implementing the code. Hack testdata has been added. Translated by ChatGPT 5