405131: GYM101804 D Dire Grades

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Dire Gradestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Students from Instituto Militar de Engenharia (IME) have a lot of exams during graduation. Naum, a former student, not being good at programming, requested you to create a program that he could use to verify his means more easily and also be able to change some of his grades.

He will give you $$$n$$$ numbers, indicating his grades, and will request $$$q$$$ queries. There are two types of queries:

  • $$$1$$$ $$$e$$$ $$$v$$$: change the grade of exam $$$e$$$ to $$$v$$$
  • $$$2$$$ $$$l$$$ $$$r$$$: print the mean of all exams between $$$l$$$ and $$$r$$$.

The mean from $$$l$$$ to $$$r$$$ is defined as $$$ \frac{\sum_{i=l}^{r} a_i} {r-l+1} $$$, with $$$a_i$$$ being the grade of exam $$$i$$$.

All real numbers will have $$$2$$$ decimals places.

Input

The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of grades.

The second line contains $$$n$$$ space separated real numbers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$0.00 \leq a_i \leq 10.00$$$), where $$$a_i$$$ is the grade on exam $$$i$$$.

The third line contains one integer $$$q$$$ ($$$1 \leq q \leq 10^5$$$).

The next $$$q$$$ lines contains, each, one integer $$$t_i$$$ ($$$1 \leq t_i \leq 2$$$), indicating the type of the query $$$i$$$, and two other values, described below, depending on the query type.

If $$$t_i$$$ is $$$1$$$, the values are one integer $$$e_i$$$ and one real number $$$v_i$$$ ($$$1 \leq e_i \leq n$$$, $$$0.00 \leq v_i \leq 10.00$$$) — the exam that will change de grade and the new grade of the exam.

If $$$t_i$$$ is $$$2$$$, the values are two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \leq l_i \leq r_i \leq n$$$) — the interval limits to take the median.

It's guaranteed that at least one query is of type $$$2$$$.

Output

For every query of type $$$2$$$, print one line with the mean of all exams in the given interval.

The error between the answer and the printed value must not exceed $$$10^{-6}$$$ in absolute value.

ExamplesInput
1
10.00
3
2 1 1
1 1 8.50
2 1 1
Output
10.000000
8.500000
Input
3
4.00 6.00 8.00
3
2 1 3
1 2 10.00
2 1 3
Output
6.000000
7.333333

加入题单

算法标签: