← 返回 stripe 的题目列表Calculate Order Total Cost with Incremental Shipping Rates
类型:online_judge
An order has multiple products, each with different quantities and price brackets. Calculate the total price by determining which quantity range each product falls into, where maxQuantity = null indicates no upper limit.
Input:
An order object including product name, a list of price brackets (with maxQuantity), and quantity.
Output: The total price calculated based on the quantities and price brackets.
Example:
Input: Order = [{"name": "mouse", "price": [{"maxQuantity": 10, "unitPrice": 500}, {"maxQuantity": null, "unitPrice": 400}], "quantity": 15}]
Output: 6800
Example
Input
{"order": [{"name": "keyboard", "price": [{"maxQuantity": 5, "unitPrice": 200}, {"maxQuantity": null, "unitPrice": 150}], "quantity": 7}]}