C# BackTracking, using PriorityQueue and HashSet
\n        public int ClosestCost(int[] baseCosts, int[] toppingCosts, int target)\n        {\n\t\t    //min-heap, why priority type is double ? because we need 
```\n        public int ClosestCost(int[] baseCosts, int[] toppingCosts, int target)\n        {\n\t\t    //min-heap, why priority type is double ? because we need return smaller one if same values exist, so for value>target, add 0.5 on it\n            PriorityQueue<int,double> pq = new PriorityQueue<int,double>();\n            foreach(var bCost in baseCosts)\n            {\n                var set = new HashSet<int>() { bCost };\n                foreach(var topping in toppingCosts)\n                {\n                    var next = new HashSet<int>();\n                    foreach(var i in set)\n                    {\n                        next.Add(i);//no current  topping\n                        next.Add(i + topping);//1 current  topping\n                        next.Add(i + topping * 2);//2 current  topping\n                    }\n                    set = next;\n                    foreach(var i in set)\n                    {\n                        if (i == target) return i;//if equal to target just return\n                        else if (i < target) pq.Enqueue(i, target - i);\n                        else pq.Enqueue(i,i- target+0.5);//if >target, add 0.5\n                    }\n                }\n            }\n            return pq.Peek();//return the top of heap\n        }\n\n```
[]