A12186 | Kvass and the Fair Nut
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$ -th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.
Help him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.
Help him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.
输入格式
The first line contains two integers $n$ and $s$ ( $1 \le n \le 10^3$ , $1 \le s \le 10^{12}$ ) — the number of kegs and glass volume.
The second line contains $n$ integers $v_1, v_2, \ldots, v_n$ ( $1 \le v_i \le 10^9$ ) — the volume of $i$ -th keg.
The second line contains $n$ integers $v_1, v_2, \ldots, v_n$ ( $1 \le v_i \le 10^9$ ) — the volume of $i$ -th keg.
输出格式
If the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$ . Otherwise, print a single integer — how much kvass in the least keg can be.
输入输出样例
输入 #1
3 3 4 3 5
输出 #1
3
输入 #2
3 4 5 3 4
输出 #2
2
输入 #3
3 7 1 2 3
输出 #3
-1
In the first example, the answer is $3$ , the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.
In the second example, the answer is $2$ , the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.
In the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$ .
In the second example, the answer is $2$ , the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.
In the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted