Problem Description:A company is planning a sequence of marketing campaigns over several…
- User
Problem Description:A company is planning a sequence of marketing campaigns over several weeks. Each campaign incurs a specific cost, and they aim to launch at least one campaign per week. The objective is to plan the campaigns in such a way that minimizes the total weekly input, where the weekly input is defined as the maximum cost of any campaign planned during that week.Given:An array costs[] where each element represents the cost of a campaign.An integer weeks representing the number of weeks available for the campaigns.Your task is to return the minimum sum of weekly inputs that can be achieved through optimal scheduling. Campaigns must be organized in the same order as they appear in the costs[] array.Function Overview:def minimumWeeklyInput(costs, weeks): # Your code here to implement the optimal campaign schedulingInput:costs[]: A list of integers where each integer represents the cost of a campaign.weeks: An integer representing the number of weeks for scheduling the campaigns.Output:Return an integer representing the minimum total sum of the weekly inputs.Constraints:The campaigns must be scheduled in the same order as they appear in the costs[] array.There must be at least one campaign planned for each week.Example 1:Input:costs = [1000, 500, 2000, 8000, 1500] weeks = 3Output:9500Explanation:The optimal plan is:Week 1: First campaign → cost = 1000Week 2: Second campaign → cost = 500Week 3: Remaining campaigns → max(2000, 8000, 1500) = 8000Total minimum weekly input: 1000 + 500 + 8000 = 9500.Example 2:Input:costs = [3000, 1000, 4000] weeks = 2Output:7000Explanation:The optimal plan is:Week 1: First campaign → cost = 3000Week 2: Remaining campaigns → max(1000, 4000) = 4000Total minimum weekly input: 3000 + 4000 = 7000.Example 3:Input:costs = [130, 200, 460, 499, 450, 350] weeks = 3Output:849Explanation:The optimal plan is:Week 1: First campaign → cost = 130Week 2: Next four campaigns → max(200, 460, 499, 450) = 499Week 3: Last campaign → cost = 160Total minimum weekly input: 130 + 499 + 160 = 849.The goal of the function is to distribute the campaigns optimally across the weeks, ensuring the minimum possible sum of weekly maximum costs.
- Assistant