Build a marginal tax calculator There have been some tax rate calculator problems here that depend on defined rates (specifically US federal rates), but none that have done it for arbitrary lists.

Your task is to build a program or function that will take an arbitrary list of marginal tax brackets and calculate the effective amount of tax paid on a given amount of taxable income.

Your program will take as input:


N pairs of numbers in the form (amt, rate), each representing a tax bracket.


amt is the amount of taxable income above which at which the tax rate starts to apply. These amounts will all be integers, and appear in increasing order.
rate is the tax rate, expressed as a decimal percentage from 0 to 100 inclusive.

The amount of taxable income, as a nonnegative integer.


If no rate is specified for $0, the rate is assumed to be 0%.

Alternatively, your program can also take as input two lists (amt1, amt2, ...) and (rate1, rate2, ...), containing the amounts and rates in the same order.

Your program will then output the payable tax, either to two decimal places, or rounded down to the nearest whole currency unit.



An example input (the most recent Canadian tax brackets, from 2016, with the basic personal tax credit applied and nothing else):

11474 15
45282 20.5
90563 26
140388 29
200000 33

393216


And its corresponding output:

108357.07  or  108357




The shortest program in any language to do this wins.
Haskell, 67 66 bytes

Thanks Damien for -1 byte.

This solution is in the form of an infix function, ?, of type (Integral b, RealFrac r) =&gt; [(r, r)] -&gt; r -&gt; b. The helper function, #, does the required calculations while ? serves to handle the IO specifications.

a?b=floor$reverse a#b
((m,p):r)#i|v&lt;-min i m=p/100*(i-v)+r#v
_#_=0