#P15872. [NOI1998] 个人所得税

[NOI1998] 个人所得税

Background

NOI1998 D1T1.

Problem Description

A country's individual income tax law stipulates that the main taxable income items for ordinary citizens and the tax amounts are as follows.

For wages and salaries, tax is calculated monthly. The taxable income for a month is the monthly income minus a deduction of 800800 yuan. The tax rates are shown in the table below.

Bracket Monthly taxable income Tax rate
11 The part not exceeding 500500 yuan 5%5\%
22 The part from 500500 to 20002000 yuan 10%10\%
33 The part from 20002000 to 50005000 yuan 15%15\%
44 The part from 50005000 to 2000020000 yuan 20%20\%
55 The part from 2000020000 to 4000040000 yuan 25%25\%
66 The part from 4000040000 to 6000060000 yuan 30%30\%
77 The part from 6000060000 to 8000080000 yuan 35%35\%
88 The part from 8000080000 to 100000100000 yuan 40%40\%
99 The part exceeding 100000100000 yuan 45%45\%

For one-time labor remuneration income, tax is calculated per payment. If a single payment does not exceed 40004000 yuan, deduct 800800 yuan; if it exceeds 40004000 yuan, deduct 20%20\% as expenses, and the remaining amount is the taxable income. The tax rates are shown in the table below.

Bracket Taxable income per payment Tax rate
11 The part not exceeding 2000020000 yuan 20%20\%
22 The part from 2000020000 to 5000050000 yuan 30%30\%
33 The part exceeding 5000050000 yuan 40%40\%

From the above, we can see that both wages/salaries and one-time labor remuneration income are taxed using a progressive tax rate (marginal tax rate). The progressive tax rate divides the taxable income into several brackets by amount. Each bracket has a tax rate, and the rates increase bracket by bracket. For each taxpayer, their taxable income is split across the brackets it falls into, each part is taxed at the corresponding rate, and the sum of these results is the total tax payable.

For example, suppose a person's total wage for a certain month is 38003800 yuan. After subtracting 800800 yuan, the taxable income is 30003000 yuan. This includes 500500 yuan in bracket 11, 15001500 yuan in bracket 22, and 10001000 yuan in bracket 33. The tax rates are 5%5\%, 10%10\%, and 15%15\%, respectively. The total tax payable is 500×5%+1500×10%+1000×15%=325500\times5\%+1500\times10\%+1000\times15\%=325. The calculation process is shown in the figure below.

::::align{center} ::::

Now you need to write a program that, given all income information (income type, income time, income amount) for all employees of a company within one year, calculates the total individual income tax payable by all employees of the company for that year.

Input Format

The first line contains a positive integer MM (M50000M\leq50000), which is the total number of employees in the company (employee IDs are 1,2,,M1,2,\cdots,M).
Each of the following lines describes one income record of an employee within the year, in the following format:

  • Wages and salaries income record: PAY employee_id income_time income_amount;
  • One-time labor remuneration income record: INCOME employee_id income_time income_amount.

Among them, the income time format is: MM/DD\tt{MM/DD}. MM\tt{MM} denotes the month (1MM121\leq \tt{MM}\leq 12), and DD\tt{DD} denotes the day (1DD311\leq \tt{DD}\leq 31). The income amount is a positive integer (unit: yuan), and assume that for each person, each income amount is less than 10610^6 yuan.

The input ends with the character #. In the input file, adjacent items on the same line are separated by one or more spaces.

Output Format

Output a single positive number PP, which is the total individual income tax payable by all employees of the company within the year (unit: yuan). Keep two digits after the decimal point.

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
#
5476.60

Hint

  • Subtask 0 uses the official CCF testdata, with lower difficulty.
  • Subtask 1 uses community testdata.

Translated by ChatGPT 5