Logo
(追記) (追記ここまで)

33265번 - Find And Modify 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 2048 MB0000.000%

문제

You are given a permutation $a_1, \ldots, a_n$. You need to maintain a sequence $b_1, \ldots, b_n$ initialized by zeroes. Process $m$ operations of the following form:

  • Modification operation: given $\ell$ and $r,ドル for each pair $(i, j)$ such that $\ell \leq i \leq j \leq r$ and $a_i \leq a_j,ドル increment $b_j$ by 1ドル$;
  • Query operation: given $x,ドル return $b_x$.

입력

The first line of input contains two integers $n$ and $m$ (1ドル \leq n, m \leq 2 \cdot 10^5$).

The second line contains $n$ integers $a_1, \ldots, a_n$ (1ドル \leq a_i \leq n$; all $a_i$ are distinct).

Each of the next $m$ lines consists of integers and has either the form "1~$\ell$~$r$" for a modification operation or the form "2~$x$" for a query operation (1ドル \leq \ell \leq r \leq n$; 1ドル \leq x \leq n$).

You may assume that the input contains at least one query operation.

출력

For each query operation, output one line containing an integer that represents the answer.

제한

예제 입력 1

8 10
5 4 8 7 1 6 3 2
1 2 5
2 8
1 2 8
1 7 8
2 4
2 1
2 6
2 4
1 8 8
2 4

예제 출력 1

0
4
0
3
4
4

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2024 > Day 3: THird roUnd F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /