Painting the Walls

Problem Description

You have n walls to paint and a paid painter and a free painter. For each wall i: the paid painter takes time[i]+1 units (paints wall i in 1 step, costs cost[i]). While the paid painter works for time[i]+1 units, the free painter can paint time[i] additional walls at zero cost. Find the minimum cost to paint all n walls. Pattern: 0/1 knapsack DP. dp[j] = min cost to ensure j walls are covered by paid painter commitments. When you hire paid painter for wall i, paid covers 1 wall + free covers time[i] walls. Example 1: Input: cost = [1,2,3,2], time = [1,2,3,2] Output: 3 Explanation: Hire paid for wall 2 (cost=3, time=3). Free paints 3 walls. Total 4 walls painted. Example 2: Input: cost = [2,3,4,2], time = [1,1,1,1] Output: 4

Example Test Cases

Example 1
Input: [[1,2,3,2],[1,2,3,2]]
Expected: 3
Example 2
Input: [[2,3,4,2],[1,1,1,1]]
Expected: 4

Run your code to see the results