#P5356. [Ynoi Easy Round 2017] 由乃打扑克

[Ynoi Easy Round 2017] 由乃打扑克

Background

Problem Description

Yuno is not very good at playing poker.

So she came up with a data structure problem.

You are given a sequence aa of length nn. You need to support mm operations of two types:

  1. Query the kk-th smallest value in the interval [l,r][l, r].
  2. Add kk to every element in the interval [l,r][l, r].

Input Format

One line with two integers n,mn, m.

The next line contains nn integers; the ii-th integer represents aia_i.

The next mm lines each contain four integers opt,l,r,kopt, l, r, k, where optopt indicates which type of operation it is.

Output Format

For each query, output one number as the answer. If there is no solution, output 1-1.

1 1
1
1 1 1 1
1

Hint

Idea: nzhtl1477.

Solution: nzhtl1477 (O(mn(Δ+logn))O(m\sqrt{n}(\Delta+\log n))) solution, ccz181078 (O(mnlogn)O(m\sqrt{n\log n})) solution.

Code: nzhtl1477 (O(mn(Δ+logn))O(m\sqrt{n}(\Delta+\log n))) code, ccz181078 (O(mnlogn)O(m\sqrt{n\log n})) code.

Data: nzhtl1477.

Constraints: 1lrn1051\leq l\leq r \leq n\leq 10^5, 1m1051 \leq m \leq 10^5, 2×104ai,k2×104-2\times 10^4\leq a_i, k\leq 2\times 10^4, opt{1,2}opt \in \{1, 2\}.


upd 2022.8.18\text{upd 2022.8.18}: A new set of hack testdata has been added.

Translated by ChatGPT 5