Masala #REHXNNXLWJ

Xotira 32 MB Vaqt 1000 ms Qiyinchiligi 1 %
14

  

Scrooge McDaMia

All of you know Scrooge McDuck, Shohjahon recently made friends with him and he became greedy too. He decided to buy \(n\) rubber ducks. Each rubber duck has its own price. Shohjahon initially had \(m\) coins. He wants to buy as many ducks as possible, what is the maximum number of ducks he can buy?


Kiruvchi ma'lumotlar:

First line contains a number \(n\) (1 ≤ \(n\) ≤ \(10^5\)).

Second line contains a nubmer \(m\) (1 ≤ \(m\) ≤ \(10^9\)).

Next \(n\) lines each contain number \(a_i\) (1 ≤ \(a_i\) ≤ \(10^9\)), the price of the \(i\)th duck.


Chiquvchi ma'lumotlar:

Print the maximum number of rubber ducks Shohjahon can buy.


Misollar
# input.txt output.txt
1
4
5
2
1
3
4
2
Izoh:

\(a_i\) means \(i\)th element of an array \(a\).

For example in array \([1, 2, 3]\)\(a_1\) is 2 (0 based indexing).

Yechimini yuborish
Bu amalni bajarish uchun tizimga kiring, agar profilingiz bo'lmasa istalgan payt ro'yxatdan o'tishingiz mumkin