#K13516. Longest Increasing Subarray with Updates

    ID: 23930 Type: Default 1000ms 256MiB

Longest Increasing Subarray with Updates

Longest Increasing Subarray with Updates

You are given an array of n integers and m queries. There are two types of queries:

  • Type 1: "1 i d" - Increase the value at index i (1-indexed) by d.
  • Type 2: "2" - Compute the length of the longest contiguous subarray that is strictly increasing.

The task is to process all the queries in order and for every query of type 2, output the required length.

Note: The array indices are 1-indexed in the input queries.

The longest increasing subarray of an array A is defined as the maximum length L such that there exists an index i for which:

\[ A_i < A_{i+1} < \cdots

inputFormat

The input is given via stdin and has the following format:

  1. The first line contains two integers n and m separated by space.
  2. The second line contains n integers representing the initial sequence.
  3. Each of the next m lines contains a query. A query is in one of the two formats:
    • "1 i d" (for type 1 queries)
    • "2" (for type 2 queries)

outputFormat

For each query of type 2, print the length of the longest contiguous strictly increasing subarray on a separate line to stdout.

## sample
5 5
2 1 3 2 5
1 3 1
2
1 5 1
2
2
2

2 2

</p>