← 返回 amazon 的题目列表Shipping Cost Calculation
类型:online_judge
You are tasked with handling an order containing different items. Each item has a weight, and you need to calculate the shipping cost for the entire order based on the weight of each item. The shipping cost is tiered, with different weight ranges having different rates. Your task is to write a program to calculate the total shipping cost for the order.
Input
The first line is an integer n denoting the number of items in the order. The next n lines each contain an integer representing the weight of each item.
The second line is an integer m representing the number of weight ranges in the pricing table. The next m lines each contain two integers min_weight and max_weight, and a floating point number rate, which indicates the rate for that weight range.
Output
A float showing the total shipping cost for the order, rounded to two decimal places.
Test Case
Input:
3
5
10
25
2
0 20 5.0
20 50 7.5
Output:
35.00
Example
Input
3
5
10
25
2
0 20 5.0
20 50 7.5