In search of Samosa
Practice
2.6 (28 votes)
Approved
Basic programming
Easy
Open
Sorting
Problem
89% Success 9400 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code
Shiro is an avid lover of Samosas. He went down to the Samosa street to have some. But he only has K units of money with him. There are N shops on the street and unfortunately, all of them have only one samosa remaining. You are also given an array A[ ] , where Ai is the cost of a samosa on the i'th shop.
Find the maximum samosas that Shiro can eat.
Input:
First line contains two space-separated integers N and K.
Second line contains N space separated integers, the cost of a samosa on the shops.
Output:
Print the answer.
Constraints:
1 ≤ N ≤ 103
0 ≤ K ≤ 103
0 ≤ Ai ≤ 100
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
90 votes
Tags:
AlgorithmsGreedy Algorithms
Points:20
21 votes
Tags:
ApprovedBasic ProgrammingEasyGreedy AlgorithmsOpen
Points:20
7 votes
Tags:
Greedy AlgorithmsAlgorithmsBasics of Greedy AlgorithmsGreedy algorithm
Editorial
Login to unlock the editorial