408846: GYM103348 H Ophelia's Madness
Description
After the death of her father Polonius, coupled with her troubles with Hamlet, Ophelia has descended into madness. Unable to comprehend everything that is happening, she decides to retreat from the world. Ophelia goes to her personal garden and starts picking out roses in madness. Ophelia is curious about confidence intervals for the average number of petals as she goes through roses, and as such, she starts counting the number of petals for each rose she picks. Unfortunately, Ophelia is quite poor at mathematics, and wants you to help with this task.
Ophelia will give you a stream of queries of two types. The first type of query will be of the form $$$R\;c_i$$$, telling you that the $$$i^{th}$$$ rose has $$$c_i$$$ petals. The second type of query will be of the form $$$C\;t_i$$$, where Ophelia wants a $$$95\%$$$ confidence interval for the true average of the number of rose petals, based on the last $$$t_i$$$ roses. More specifically, let $$$\mu$$$ be the average of the last $$$t_i$$$ roses, and $$$\sigma$$$ be the standard deviation for the last $$$t_i$$$ roses. Then, to get a $$$95\%$$$ confidence interval, we would want $$$(\mu - 2\sigma_{\bar{x}}, \mu + 2\sigma_{\bar{x}})$$$.
Note: the confidence interval $$$(\mu - 2\sigma_{\bar{x}}, \mu + 2\sigma_{\bar{x}})$$$ is not exactly a $$$95\%$$$ confidence interval, but we will use this as an approximation for it. The standard deviation for a set of elements is defined as $$$$$$\sigma = \sqrt{\dfrac{\sum_{i = 1}^n (x_i - \mu)^2}{n}}$$$$$$ where $$$n$$$ is the total number of elements. Then, $$$$$$\sigma_{\bar{x}} = \dfrac{\sigma}{\sqrt{n}}$$$$$$
InputThe first line will contain $$$n (1 \le n \le 10^5)$$$, the total number of queries that Ophelia has.
The next $$$n$$$ lines will each contain a query $$$R\;c_i$$$ (where $$$0 \le c_i \le 10^3$$$), or $$$I\;t_i$$$ (where $$$2 \le t_i \le n_i$$$, where $$$n_i$$$ is the number of queries of the first type thus far).
OutputFor every query $$$I\;t_i$$$, output $$$\mu - 2\sigma, \mu + 2\sigma$$$ space separated on a separate line. Your answer for each query will be correct if it is within an absolute or relative error of $$$10^{-6}$$$.
ExampleInput5 R 3 R 1 I 2 R 2 I 2Output
0.585786438 3.414213562 0.792893219 2.207106781