Model Fallback Router
A production endpoint has models represented by [name, cost_cents, latency_ms, healthy]. Implement route_model(models, max_cost_cents, max_latency_ms). Return the name of the cheapest healthy model within both budgets. Break equal-cost ties by lower latency, then by input order. Return None if none qualify. All numeric values are nonnegative.
Examples
A guided view of the published example, not a trace of your code.
[[["large",8,300,true],["small",2,120,true],["backup",1,500,true]],8,350]"small"Start with the input values shown in this example.
Input: models = [["large",8,300,true],["small",2,120,true],["backup",1,500,true]], max_cost_cents = 8, max_latency_ms = 350
Output: "small"
Explanation: cheapest eligible
Input: models = [["a",3,100,true],["b",3,80,true]], max_cost_cents = 3, max_latency_ms = 200
Output: "b"
Explanation: latency tie break
Hint 1
Apply health and both budgets before ranking.
Hint 2
Compare cost first, then latency.