Income Tax
InterviewTime limit2sMemory limit1024 MB
Given income X and progressive tax brackets with thresholds U_i and rates p_i, the task is to compute the total income tax.
- Level
Easy3 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Statement
A little-known but ambitious company is building a large project to make it easier for ordinary citizens of Flatland to track their budgets. You are part of this project and must write a program that computes the income tax, which is the tax levied on earned income.
The tax rules are fairly complex and consist of parts:
- If income is less than , the tax is percent, that is, .
- If is at least and less than , the tax on the first is percent, and the tax on the remaining amount is percent. So the total tax is .
- If is at least , the tax from the earlier parts stays the same, and the remainder is taxed at percent. The total tax is .
Given income , compute the income tax.
Input
The first line contains two integers and (, ). The second line contains integers (). The third line contains integers ().
Output
Print the income tax that an honest citizen of Flatland must pay after earning units of Flatland currency, on a single line. Print the answer with exactly two digits after the decimal point.