Find And Modify
시간 제한10초메모리 제한2048 MB
배열 b를 유지하면서 각 구간 갱신마다 구간 내 a[i] <= a[j]인 모든 쌍 (i,j)에 대해 b[j]를 1 증가시키고, 점 질의에 답한다.
문제
You are given a permutation . You need to maintain a sequence initialized by zeroes. Process operations of the following form:
- Modification operation: given and , for each pair such that and , increment by ;
- Query operation: given , return .
입력
The first line of input contains two integers and ().
The second line contains integers (; all are distinct).
Each of the next lines consists of integers and has either the form "1 " for a modification operation or the form "2 " for a query operation (; ).
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.