National Olympiad in Informatics, China, 1998
A country's income tax law regulates citizens' personal income taxes to be based on their wage and income.
Wage taxation is calculated on a monthly basis.
Bracket | Base Amount Range (Each Month) | Tax Rate (%) |
---|---|---|
1 | No more than |
|
2 | More than |
|
3 | More than |
|
4 | More than |
|
5 | More than |
|
6 | More than |
|
7 | More than |
|
8 | More than |
|
9 | More than |
Income taxation is calculated independently, and separately for each payout
instance. For each payout, if the amount does not exceed
Bracket | Base Amount Range (Each Payout) | Tax Rate (%) |
---|---|---|
1 | No more than |
|
2 | More than |
|
3 | More than |
From the above, one should realize that both wage and income taxes are to be calculated in a compounded fashion. That is, one must start at the first income bracket and pay as much of that given range as possible according to the rate specified in the bracket. If there is money left over (their current amount exceeds the base amount range), then they move down to the next income bracket, where they apply as much of the excess amount as they can. This continues until they have exhausted all of the value.
For example, an individual's wage for one month is
You must write a program to help a company keep track of the taxes they have to pay for one year, given the information of all of their payouts (the type of payout, time of payout, and the amount paid). Your program must find the sum of both the wage tax and income tax for all of their employees.
Input Specification
The first line of inputs contains one integer
- Wage tax payout:
PAY ID Date Amount
- Income tax payout:
INCOME ID Date Amount
Here, ID
represents the ID of the employee being paid (an integer from
1 to Date
is the date of the payout in the format MM/DD
where
MM
is the month MM
DD
is the day DD
Amount
is the amount paid in dollars (assume that each
amount is a positive integer no larger than 1 million).
A line with the character #
denotes the end of input. Adjacent
values in the input will be separated by one or more spaces.
Output Specification
The output contains a positive number
Sample Input
2
PAY 1 2/23 3800
INCOME 2 4/8 4010
INCOME 2 4/18 800
PAY 1 8/14 6700
PAY 1 8/10 1200
PAY 2 12/10 20000
#
Sample Output
5476.60
Problem translated to English by .
Comments