Minimum Weekly Input (Planning Campaingns :)
Learn this problemProblem statement
A company will launch a series of marketing campaigns over several weeks. Each campaign has a certain cost. They want to launch at least one campaign every week, and to plan the campaigns in a way that minimizes the total weekly input. The weekly input is the maximum cost of any campaign planned in that week. Given the cost of the campaigns in a list, costs, and the number of weeks, find the minimum sum of weekly inputs that can be achieved with optimal planning. The campaigns must be organized in the same order in which they appear in the list costs.
Function
minimumWeeklyInput(costs: int[], weeks: int) → int
Complete the function minimumWeeklyInput in the editor below.
minimumWeeklyInput has the following parameters:
int costs[n]: the order and cost of the campaignsint weeks: the number of weeks to organize all the campaigns
Returns
int: the minimum possible overall weekly input
Examples
Example 1
costs = [1000, 500, 2000, 8000, 1500]weeks = 3return = 9500The company can organize the first campaign in the first week, the second campaign in the second week, and the remaining campaigns in the third week. The sum of weekly inputs in this planning is 1000 + 500 + max(2000, 8000, 1500) = 9500, which is the minimum possible input. Return 9500.
Constraints
1 ≤ n ≤ 3001 ≤ weeks ≤ n ≤ 3001 ≤ costs[i] ≤ 10^5
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026