Question bank › Greedy
Dsa Greedy Easy

Resource Allocation

You have a set of tasks, each requiring a certain amount of resources and taking a specific duration to complete. You want to maximize the number of tasks you can complete given a fixed amount of resources available. Each task has a resource requirement and a duration. No task can be started unless sufficient resources are available. Input: The first line contains two integers: total_resources (1 ≤ total_resources ≤ 1000) and n (1 ≤ n ≤ 100) - the number of tasks. Each of the next n lines contains two integers: resource_required and duration (1 ≤ resource_required ≤ 1000, 1 ≤ duration ≤ 10). Output: Print the maximum number of tasks that can be completed with the given resources. Example: Input: 10 3 3 2 4 1 2 3 Output: 3

Key concepts

greedyresource management

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.