Dsa
Greedy
Easy
Charity Event Fundraising
A charity event is set to host several fundraising activities, each requiring an investment cost. To maximize the number of activities organized under a set budget, write a program that determines how many activities can be funded within the budget.
Input format:
- The first line contains an integer B (the budget).
- The second line contains an integer A (number of activities).
- The third line contains A space-separated integers (costs of the activities).
Output format:
- A single integer representing the maximum number of activities that can be funded.
Example:
Input:
100
4
30 10 20 60
Output:
4
Key concepts
greedycombinatoricssorting
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now