← 返回 stripe 的题目列表Tiered Pricing Calculation
类型:online_judge
Given pricing tier rules and order information, calculate the total price for the order. Each order contains an item and its quantity. Example rules: 1–10 units at $1 each, 11–20 units at $0.8 each. Requirements:
Input format: Rules and order information are constructed in a dictionary, e.g., {"item1": [(1, 10, 1), (11, 20, 0.8)]} for rules, "item1, 15" for order information.
Output format: an integer representing the total price of the order.
Test Cases
Input:
item1, 15
pricing_rules = {"item1": [(1, 10, 1), (11, 20, 0.8)]}
Output:
13
Example
Input
item1, 15
pricing_rules = {"item1": [(1, 10, 1), (11, 20, 0.8)]}