Question: Python : Consider you are needed to buy the maximum number of PC within the allocated budget. For that, create function to find the maximum

Python : Consider you are needed to buy the maximum number of PC within the allocated budget. For that, create  function to find the maximum number of PC can buy within the budget. First line of the input has integers N (total no of PC for sale) and B (total budget). The second line has the N integers represents the cost of the each PC for sale, then the function should return the maximum number os PC can buy.

 

Sample Input

5  120

30  20  40  30  35

 

Sample Output

4

 

Explanation

There are 5 PC for sale with the prices 30, 20, 40, 30 and 35 and the budget is 120, out of this 4 PCs can buy.

 

Complete the code below.

 

# Enter your code here. Read input from STDIN. Print output to STDOUT

def buypc():

 

#Write your code here

 

 

 

return


 

if __name__ == "__main__":

print(buypc())

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets tackle this problem step by step The goal is to determine the maximum number of PCs that can be ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!