P24795 [AtCoder] [ABC365C] Transportation Expenses
入门
题目描述

Problem Description

There are $ N $ participants in an event, and the transportation expense for the $ i $-th person is $ A_i $ yen.

Takahashi, the organizer of the event, sets a cap $ x $ on the transportation subsidy. For person $ i $, he will provide a subsidy of $\min(x, A_i)$ yen. Here, $ x $ must be a non-negative integer.

Takahashi's budget is $ M $ yen, and he wants the total transportation subsidy for $ N $ people to be no more than $ M $ yen. What is the maximum cap $ x $ on the transportation subsidy that can be set under these conditions?

If the cap on the transportation subsidy can be infinitely large, report this instead.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ A_1 $ $ A_2 $ $\ldots$ $ A_{N} $

Output Format

Output the maximum cap $ x $ on the transportation subsidy as an integer when the budget condition is satisfied.

If the cap on the transportation subsidy can be infinitely large, output infinite instead.

Sample Input and Output

Sample Input #1

4 8
1 3 2 4

Sample Output #1

2

Sample Input #2

3 20
5 3 2

Sample Output #2

infinite

Sample Input #3

10 23
2 5 6 5 2 1 7 9 7 2

Sample Output #3

2

Notes/Hints

Constraints

  • $1\leq\ N\leq\ 2\times\ 10^5$
  • $1\leq\ M\ \leq\ 2\times\ 10^{14}$
  • $1\leq\ A_i\ \leq\ 10^9$
  • All input values are integers

Sample Explanation 1

If the cap on the transportation subsidy is set to $ 2 $ yen, the total subsidy for $ N $ people is $\min(2,1)\ +\ \min(2,3)\ +\ \min(2,2)\ +\ \min(2,4)\ =\ 7$ yen, which is within the budget of $ 8 $ yen. If the cap is set to $ 3 $ yen, the total subsidy becomes $\min(3,1)\ +\ \min(3,3)\ +\ \min(3,2)\ +\ \min(3,4)\ =\ 9$ yen, exceeding the budget of $ 8 $ yen. Therefore, the maximum cap on the transportation subsidy is $ 2 $ yen.

Sample Explanation 2

The cap on the transportation subsidy can be infinitely large.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 8 1 3 2 4
样例输出
2