Dsa
Dynamic Programming
Warm-up
Storehouse Scheduling
A storehouse has a number of days to deliver orders, and each order takes a certain number of days to prepare. You need to determine the maximum number of days the storehouse can allocate sequentially for preparing the orders without exceeding the total number of days available. Each order's preparation time is given in days. Write a program to find the maximum number of preparation days that can be allocated.
Input format:
- The first line contains an integer N (1 ≤ N ≤ 100).
- The second line contains N space-separated integers representing the preparation days for each order.
Output format:
- A single integer indicating the maximum number of preparation days that can be allocated.
Example:
Input:
5
2 3 1 4 1
Output:
11
Key concepts
dynamic_programminggreedyintervals
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