Created
October 29, 2019 14:21
-
-
Save imedadel/4c7fac3877050cde402c58b80c1a9953 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| toys, budget = [int(x) for x in input().strip().split()] | |
| spent = 0 | |
| bought = 0 | |
| prices = [int(x) for x in input().strip().split()] | |
| prices.sort() | |
| for price in prices: | |
| if spent + price <= budget: | |
| spent += price | |
| bought += 1 | |
| else: | |
| break | |
| print(bought) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment