CF1084B.Kvass and the Fair Nut

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Fair Nut likes kvass very much. On his birthday parents presented him nn kegs of kvass. There are viv_i liters of kvass in the ii-th keg. Each keg has a lever. You can pour your glass by exactly 11 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by ss 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 ss liters of kvass.

公平的坚果非常喜欢格瓦斯。在他生日那天,父母送给他 nn 桶格瓦斯。第 ii 个桶中有 viv_i 升格瓦斯。每个桶上都有一个杠杆,每次拉动该杠杆恰好可以倒出 11 升格瓦斯倒入杯中。公平的坚果非常喜欢这种饮料,因此他想总共倒出 ss 升格瓦斯到自己的杯中。但他希望以一种方式完成倒酒操作,使得剩余格瓦斯量最少的那个桶中的格瓦斯量尽可能多。

请帮助他求出:在满足倒出 ss 升的前提下,剩余格瓦斯量最少的那个桶中最多可能剩下多少升格瓦斯;或者判断根本无法倒出 ss 升格瓦斯。

输入格式

The first line contains two integers nn and ss (1≤n≤1031 \le n \le 10^3, 1≤s≤10121 \le s \le 10^{12}) — the number of kegs and glass volume.

The second line contains nn integers v1,v2,…,vnv_1, v_2, \ldots, v_n (1≤vi≤1091 \le v_i \le 10^9) — the volume of ii-th keg.

第一行包含两个整数 nn 和 ss(1≤n≤1031 \le n \le 10^3,1≤s≤10121 \le s \le 10^{12})—— 分别表示酒桶的数量和玻璃杯的容量。

第二行包含 nn 个整数 v1,v2,…,vnv_1, v_2, \ldots, v_n(1≤vi≤1091 \le v_i \le 10^9)—— 表示第 ii 个酒桶的容量。

输出格式

If the Fair Nut cannot pour his glass by ss liters of kvass, print −1-1. Otherwise, print a single integer — how much kvass in the least keg can be.

如果公平的坚果无法倒出 ss 升克瓦斯,则输出 −1-1;否则,输出一个整数——剩余克瓦斯量最少的酒桶中所剩的克瓦斯量。

输入输出样例

  • 输入#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 33, the Fair Nut can take 11 liter from the first keg and 22 liters from the third keg. There are 33 liters of kvass in each keg.

In the second example, the answer is 22, the Fair Nut can take 33 liters from the first keg and 11 liter from the second keg.

In the third example, the Fair Nut can't pour his cup by 77 liters, so the answer is −1-1.

在第一个例子中,答案是 33,公平的坚果可以从第一个酒桶中取 11 升,从第三个酒桶中取 22 升。此时每个酒桶中都剩余 33 升克瓦斯。

在第二个例子中,答案是 22,公平的坚果可以从第一个酒桶中取 33 升,从第二个酒桶中取 11 升。

在第三个例子中,公平的坚果无法倒出 77 升克瓦斯,因此答案为 −1-1。

输入解题思路,AI测评打分。不知道怎么写?

首页