Dsa
Greedy
Easy
Fund Allocation to Projects
A non-profit organization has a limited budget to allocate among several projects, each with a requested amount and a potential impact score. The organization wants to maximize the total impact while not exceeding its budget.
Input format:
- The first line contains an integer b (1 ≤ b ≤ 100) - the total budget.
- The second line contains an integer p (1 ≤ p ≤ 100) - the number of projects.
- The next p lines each contain two integers, request and impact (0 ≤ request ≤ 100, 0 ≤ impact ≤ 100) representing the budget request and potential impact of each project.
Output format:
- A single integer representing the maximum total impact that can be achieved within the budget.
Example:
Input:
10
3
5 20
3 15
7 25
Output:
35
Key concepts
greedyevaluationsorting
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