#ds104. 树状数组二分

树状数组二分

Fenwick Tree Binary Search

Problem Description

You are given nn numbers a1,a2,a3,…,ana_1, a_2, a_3, \dots, a_n.

You must support qq operations:

  1. 1 x d: set ax=da_x = d.
  2. 2 s: find the largest TT (0≤T≤n0 \le T \le n) such that ∑i=1Tai≤s\sum_{i=1}^{T} a_i \le s.

Input Format

The first line contains two integers nn and qq (1≤n,q≤2×1051 \le n, q \le 2 \times 10^5).

The next line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \le a_i \le 10^9).

The following qq lines each describe an operation of the form 1 x d or 2 s, with 1≤x≤n1 \le x \le n, 1≤d≤1091 \le d \le 10^9, and 1≤s≤10141 \le s \le 10^{14}.

Output Format

For each query, output one line containing the answer.

Sample Input

5 5
1 2 3 4 5
2 6
2 5
1 1 100
2 10
2 1000

Sample Output

3
2
0
5

Constraints

1≤n,q≤2×1051 \le n, q \le 2 \times 10^5, 1≤ai,d≤1091 \le a_i, d \le 10^9, 1≤s≤10141 \le s \le 10^{14}, 1≤x≤n1 \le x \le n.