Convex hull tower cost
You must build a tower from a subset (in the given order) of n blocks. dp[i] is the minimum cost to end a valid build at block i, defined by dp[i] = min over j < i of (dp[j] + a[j] * b[i]) with dp[0] = 0, where a is non-increasing and b is non-decreasing (so the convex-hull / Li-Chao optimization applies). Return dp[n-1]. Inputs: arrays a and b of equal length n, with a[0] used as the base. Constraints: 1 <= n <= 100000, values fit in normal ints. A naive O(n^2) is too slow at the top range; the lines a[j]*x have non-increasing slopes queried at non-decreasing x.
min_build_cost(a: list[int], b: list[int]) → int[[5,3,2],[1,2,4]]out20State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[5,3,2],[1,2,4]]20not run yetsample