1084B.md (1709B)
1 Source: https://codeforces.com/problemset/problem/1084/B 2 3 B. Kvass and the Fair Nut 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23 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. 24 25 Input 26 27 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. 28 29 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. 30 31 Output 32 33 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. 34 35 Examples 36 37 Input 38 39 ``` 40 3 3 41 4 3 5 42 ``` 43 44 Output 45 46 ``` 47 3 48 ``` 49 50 Input 51 52 ``` 53 3 4 54 5 3 4 55 ``` 56 57 Output 58 59 ``` 60 2 61 ``` 62 63 Input 64 65 ``` 66 3 7 67 1 2 3 68 ``` 69 70 Output 71 72 ``` 73 -1 74 ``` 75 76 Note 77 78 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. 79 80 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. 81 82 In the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.