luogu#P4915. 帕秋莉的魔导书

    ID: 3660 远端评测题 2000ms 250MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>线段树树状数组Special Judge前缀和

帕秋莉的魔导书

Background

Patchouli has a huge library with tens of thousands of books, most of which are magic books.

Problem Description

A magic book is a kind of book that requires a key to understand. However, only someone whose proficiency is equal to or higher than the author can see the key. Therefore, each magic book has its own level aia_i, and it also has its own knowledge value wiw_i. Now we want to know how much knowledge a creature with level bib_i can gain from these magic books.

Unfortunately, each creature does not know its exact level, only an approximate range of levels. You need to compute the expected knowledge value that the creature can obtain.

Input Format

The first line contains two positive integers n,mn, m, representing the initial number of books and the number of operations.

The next nn lines each contain two positive integers aia_i and wiw_i, representing the level and the knowledge value of each book.

The next mm lines each contain 22 or 33 positive integers.

Operation 1: Format: 1 x y. Meaning: query the expected knowledge value that a creature with level in [x,y][x, y] can obtain.

Operation 2: Format: 2 x y. Meaning: the library acquires a new magic book with level xx and knowledge value yy.

Output Format

Output several lines of real numbers, which are the results of all Operation 1 queries. Print each answer to four decimal places.

5 5
1 1
2 1
3 1
4 1
5 1
1 2 5
1 1 5
1 3 5
2 1 5
1 1 2
3.5000
3.0000
4.0000
6.5000

Hint

For 30%30\% of the testdata, it is guaranteed that 11 \le all input numbers 103\le 10^3.

For 100%100\% of the testdata, it is guaranteed that 1n,m1051 \le n, m \le 10^5. For the other numbers, they are guaranteed to be within the range of 32-bit signed integers (and all numbers during computation are guaranteed to be within 2632631-2^{63} \sim 2^{63} - 1).

Translated by ChatGPT 5