Moo (En)
Moo (En)
Moo
After mastering every algorithm in existence, you have decided to look for new things to do. You have
heard about Mr. Pepe, who hasn’t got bored even after mastering every algorithm. He now runs a
large poultry farm, which has n chickens. The weight of i-th chicken is w[i].
To make a friendship with Mr. Pepe, you want to distribute the biscuits among the chickens. However,
you are an artist (as is every programmer), so you want to distribute the biscuits in a fair manner. The
number of biscuits received by a chicken should be proportional to its weight. Formally, Let f [i] be
the number of biscuits received by the i-th chicken. Then the following condition must be satisfied:
f [i] w[i]
= , for every 1 ≤ i, j ≤ n
f [j] w[j]
You have m biscuits. What is the maximum number of biscuits you can distribute satisfying the above
condition?
Input
Read the input from the standard input in the following format:
line 1 : n m
line 2 : w[1] w[2] … w[n]
Output
Write the output to the standard output in the following format:
Constraints
1 ≤ n ≤ 200 000
1 ≤ m ≤ 10 15
1 ≤ w[i] ≤ 10 9 (for all 1 ≤ i ≤ n)
Subtasks
1. (2 points) n = 1
2. (4 points) m = 1
moo (1 of 2)
3. (19 points) n = 2
4. (10 points) n ≤ 100 , w[i] ≤ 100 , m ≤ 10 5
5. (15 points) w[i] = w[j] (for all 1 ≤ i, j ≤ n)
6. (20 points) There is at least one i such that w[i] = 1 .
7. (30 points) No further constraints.
Examples
Example 1
3 12
1 1 3
10
Example 2
5 10
1 5 2 3 1
0
Here, you cannot distribute any number of biscuits in a fair manner. Thus the answer is 0 .
Example 3
1 5
7
5
Here you have 5 biscuits and 1 chicken. You should give all your biscuits to the single chicken.
moo (2 of 2)