You are tasked with painting a row of n fences. You have three different paints available, labeled A, B, and C. The cost to paint the i-th fence with paint A is costs[i][0], with paint B is costs[i][1], and with paint C is costs[i][2].
Adjacent fences must not be painted with the same paint. In other words, you cannot choose the same paint for two consecutive fences.
Return the minimum total cost required to paint all the fences.
Example 1:
Input: costs = [[1,5,3],[2,9,4],[3,1,7]]
Output: 6
Explanation: Paint fence 0 with A (cost 1), fence 1 with C (cost 4), fence 2 with B (cost 1). Total = 1 + 4 + 1 = 6. Another valid sequence (C, A, B) also yields 6.
Example 2:
Input: costs = [[7,6,2],[1,5,3],[4,8,6],[3,2,9]]
Output: 11
Example 3:
Input: costs = [[5,10,15]]
Output: 5
Constraints:
1 <= costs.length <= 200costs[i].length == 31 <= costs[i][j] <= 10,000