BrazeOA #1
Shopping Cart Billing
Estimated EasyJudge-ready
Topics (AI-labelled)HashingSimulation
For each item, choose the lowest price among its original price and all valid discounts; percentage discounts are rounded down per item before the cart total is computed.
This site's standard I/O format and supplementary bounds follow this problem's statement.
Input
The first line contains the number of items n and the number of discount tags d (≤1000). The next n lines are price tagCount tag..., with tagCount=0 when there are no tags; then d lines tag type amount. type=0 is a discounted price, 1 is a percentage discount, and 2 is a fixed amount off.
Output
Output the sum of the lowest prices of all items. Tag names are unique; discount amounts are non-negative, percentages are ≤100, and a fixed amount off does not exceed the item's original price.
Example 1
Input:
2 2
10 2 sale pct
7 1 sale
sale 2 3
pct 1 50
Output:
9
Example 2
Input:
1 1
11 0
flat 0 4
Output:
11
Example 3
Input:
4 1
5 2 b c
50 1 b
21 2 b c
19 1 a
a 2 2
Output:
93
Editorial
Loading solution…