DP - Faster than 100% Python3 submissions.
Complexity: O((m+n) * k) where k <=10^4\n\n\nclass Solution:\n    def closestCost(self, baseCosts: List[int], toppingCosts: List[int], target: int) -> int:\n   
Complexity: O((m+n) * k) where k <=10^4\n\n```\nclass Solution:\n    def closestCost(self, baseCosts: List[int], toppingCosts: List[int], target: int) -> int:\n        # Tighter bound as all the values are <= 10**4\n        limit = 2*10**4+1\n        sums = [0]*limit\n        sums[0] = 1\n        \n        # DP to calculate all possible sums of toppingCosts\n        # Each iteration below calculates all possible sum from beginning until t.\n        for t in toppingCosts:\n            for i in range(limit-1,-1,-1):\n                if sums[i]:\n                    if i+t < limit:\n                        sums[i+t] = 1\n                    if i+2*t < limit:\n                        sums[i+2*t] = 1\n\n        min_diff = sys.maxsize\n        res = sys.maxsize\n        \n        for b in baseCosts:\n            for i in range(limit):\n                if not sums[i]:\n                    continue\n                if abs(b+i-target) < min_diff or (abs(b+i-target) == min_diff and b+i < res):\n                    res = b+i\n                    min_diff = abs(b+i-target)\n        \n        return res\n```
[]