A9555 | Chemistry Experiment
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
One day two students, Grisha and Diana, found themselves in the university chemistry lab. In the lab the students found $n$ test tubes with mercury numbered from $1$ to $n$ and decided to conduct an experiment.
The experiment consists of $q$ steps. On each step, one of the following actions occurs:
1. Diana pours all the contents from tube number $p_{i}$ and then pours there exactly $x_{i}$ liters of mercury.
2. Let's consider all the ways to add $v_{i}$ liters of water into the tubes; for each way let's count the volume of liquid (water and mercury) in the tube with water with maximum amount of liquid; finally let's find the minimum among counted maximums. That is the number the students want to count. At that, the students don't actually pour the mercury. They perform calculations without changing the contents of the tubes.
Unfortunately, the calculations proved to be too complex and the students asked you to help them. Help them conduct the described experiment.
The experiment consists of $q$ steps. On each step, one of the following actions occurs:
1. Diana pours all the contents from tube number $p_{i}$ and then pours there exactly $x_{i}$ liters of mercury.
2. Let's consider all the ways to add $v_{i}$ liters of water into the tubes; for each way let's count the volume of liquid (water and mercury) in the tube with water with maximum amount of liquid; finally let's find the minimum among counted maximums. That is the number the students want to count. At that, the students don't actually pour the mercury. They perform calculations without changing the contents of the tubes.
Unfortunately, the calculations proved to be too complex and the students asked you to help them. Help them conduct the described experiment.
输入格式
The first line contains two integers $n$ and $q$ ( $1<=n,q<=10^{5}$ ) — the number of tubes ans the number of experiment steps. The next line contains $n$ space-separated integers: $h_{1},h_{2},...,h_{n}$ ( $0<=h_{i}<=10^{9}$ ), where $h_{i}$ is the volume of mercury in the $і$ -th tube at the beginning of the experiment.
The next $q$ lines contain the game actions in the following format:
- A line of form " $1$ $p_{i}$ $x_{i}$ " means an action of the first type ( $1<=p_{i}<=n; 0<=x_{i}<=10^{9}$ ).
- A line of form " $2$ $v_{i}$ " means an action of the second type ( $1<=v_{i}<=10^{15}$ ).
It is guaranteed that there is at least one action of the second type. It is guaranteed that all numbers that describe the experiment are integers.
The next $q$ lines contain the game actions in the following format:
- A line of form " $1$ $p_{i}$ $x_{i}$ " means an action of the first type ( $1<=p_{i}<=n; 0<=x_{i}<=10^{9}$ ).
- A line of form " $2$ $v_{i}$ " means an action of the second type ( $1<=v_{i}<=10^{15}$ ).
It is guaranteed that there is at least one action of the second type. It is guaranteed that all numbers that describe the experiment are integers.
输出格式
For each action of the second type print the calculated value. The answer will be considered correct if its relative or absolute error doesn't exceed $10^{-4}$ .
输入输出样例
输入 #1
3 3 1 2 0 2 2 1 2 1 2 3
输出 #1
1.50000 1.66667
输入 #2
4 5 1 3 0 1 2 3 2 1 1 3 2 2 3 2 4
输出 #2
1.66667 1.00000 2.33333 2.66667
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted