NOI '98 P1 - Personal Income Tax

View as PDF

Submit solution

Points: 7
Time limit: 0.6s
Memory limit: 16M

Problem type
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. 800 dollars worth of fees are subtracted from one's total monthly wage, and the result is used as the base amount from which their personal income tax is calculated. The tax rate is outlined in the following table:

Bracket Base Amount Range (Each Month) Tax Rate (%)
1 No more than 500 dollars 5
2 More than 500 dollars, up to 2\,000 dollars 10
3 More than 2\,000 dollars, up to 5\,000 dollars 15
4 More than 5\,000 dollars, up to 20\,000 dollars 20
5 More than 20\,000 dollars, up to 40\,000 dollars 25
6 More than 40\,000 dollars, up to 60\,000 dollars 30
7 More than 60\,000 dollars, up to 80\,000 dollars 35
8 More than 80\,000 dollars, up to 100\,000 dollars 40
9 More than 100\,000 dollars 45

Income taxation is calculated independently, and separately for each payout instance. For each payout, if the amount does not exceed 4\,000 dollars, then 800 dollars of fees is taken away to get the base amount. If the amount exceeds 4\,000 dollars, then 20\% of that is subtracted to yield the base amount. The base amount is then used to calculate the income tax rate.

Bracket Base Amount Range (Each Payout) Tax Rate (%)
1 No more than 20\,000 dollars 20
2 More than 20\,000 dollars, up to 50\,000 dollars 30
3 More than 50\,000 dollars 40

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 3\,800 dollars. After subtracting 800 dollars of fees, they apply the remaining 3\,000 dollars to each of the income brackets. Bracket 1 is completely filled with 500 dollars, bracket 2 is completely filled with 1\,500 dollars, and bracket 3 gets the remaining 1\,000 dollars. The rates applied to the brackets are respectively 5\%, 10\%, and 15\%. Thus the total wage tax for that month is 500 \times 5\% + 1\,500 \times 10\% + 1\,000 \times 15\% = 325 (dollars). The calculating process is outlined in the figure given on the left.

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 M (M \le 50\,000), the number of employees in the company. The remaining lines each describe the information for one payout instance. There are two possible formats:

  • 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 M), Date is the date of the payout in the format MM/DD where MM is the month (1 \le MM \le 12), DD is the day (1 \le DD \le 31), and 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 P, the total amount of tax (wage and income) that the company must pay on behalf of all of its employees for that year in dollars. This value must be rounded and displayed to 2 decimal places.

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 Alex.


Comments

There are no comments at the moment.