A7752 | Average Superhero Gang Power
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$ , respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$ . They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$ , respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$ . They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
输入格式
The first line contains three integers $n$ , $k$ and $m$ ( $1 \le n \le 10^{5}$ , $1 \le k \le 10^{5}$ , $1 \le m \le 10^{7}$ ) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \le a_i \le 10^{6}$ ) — the initial powers of the superheroes in the cast of avengers.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \le a_i \le 10^{6}$ ) — the initial powers of the superheroes in the cast of avengers.
输出格式
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$ .
Formally, let your answer be $a$ , and the jury's answer be $b$ . Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$ .
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$ .
Formally, let your answer be $a$ , and the jury's answer be $b$ . Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$ .
输入输出样例
输入 #1
2 4 6 4 7
输出 #1
11.00000000000000000000
输入 #2
4 2 6 1 3 2 3
输出 #2
5.00000000000000000000
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted