Market :Today is Sunday and Disha is out for the shopping. She has reached to the famous market of the city. She has a list of items which she wants to buy but she has a very low amount of cash today and no shop accepts any online payment method in the market. Disha has only D rupees with her and wants to buy N items (she wants to buy as many units of item as possible). She wants to shop in a way such that first she buy 1 quantity of all the items she wants to buy and then she will move to buy 2nd quantity of any item.
Can you help her by calculating how many items she can buy today if she shops optimally?
You are given an array which represents the price of items Disha wants to buy.
If she wants to buy 4 items having price 4, 6, 2, 5 respectively and has 49 rupees only then she will buy in this order:- 1st item, 2nd item, 3rd item, 4th item (It will cost 17 rupees). Again she will buy in this order 1st, 2nd, 3rd, 4th (it will cost 17 rupees). Now, she has remaining 15 rupees so she can buy any 3 items.
The first line of input consists of two space-separated integers, N (number of items Disha wants to buy) and D (amount of cash Disha has with her).
The second line of input consists of N space-separated integers which represents the price of the N items Disha wants to buy.
1<= N <=1e9
1<= Ni <=10^15 (1e15)
1<= D <=10^18 (1e18)
Print the count of items which Disha can buy.
Example : 5,24
1 freelance fait une offre moyenne de ₹1500 pour ce travail
I can solve it. Hello, I have good knowledge of OOP and data structure and algorithms. I have solved 300+ ACM problems. I have programming expertise on C, C++, Java, Python. I have coding test experience on hackerra Plus