A company is planning to launch a series of marketing campaigns over a certain number of…
- User
A company is planning to launch a series of marketing campaigns over a certain number of weeks. Each campaign has a specific cost, and the company needs to schedule these campaigns in such a way that every week includes at least one campaign. The goal is to minimize the total weekly cost input.
The weekly input is defined as the maximum cost of any campaign scheduled for that week. Given the list of campaign costs,
costs, and the number of weeks,weeks, find the minimum possible sum of weekly inputs with optimal planning. The campaigns must be scheduled in the same order as they appear in the list.Example:
If there are 5 campaigns with costs
[1000, 500, 2000, 8000, 1500]and 3 weeks, one optimal way to organize the campaigns is:- Week 1: Campaign 1 with cost 1000
- Week 2: Campaign 2 with cost 500
- Week 3: Campaigns 3, 4, and 5 with costs 2000, 8000, and 1500
The weekly input would be:
1000 + 500 + max(2000, 8000, 1500) = 9500, which is the minimum possible input.Task:
Write a function
minimumWeeklyInput(costs, weeks)that returns the minimum sum of weekly inputs that can be achieved with optimal scheduling.Function Signature:
int minimumWeeklyInput(vector<int>& costs, int weeks);Constraints:
1 ≤ n ≤ 300(wherenis the number of campaigns)1 ≤ weeks ≤ n1 ≤ costs[i] ≤ 100000
- Assistant