Under construction

Still being built. Things may change

Income Tax

Interview

Time limit2sMemory limit1024 MB

Summary
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 k+1k + 1 parts:

  • If income XX is less than U1U_1, the tax is p1p_1 percent, that is, X⋅p1100X \cdot \frac{p_1}{100}.
  • If XX is at least U1U_1 and less than U2U_2, the tax on the first U1U_1 is p1p_1 percent, and the tax on the remaining amount is p2p_2 percent. So the total tax is U1⋅p1100+(X−U1)⋅p2100U_1 \cdot \frac{p_1}{100} + (X - U_1) \cdot \frac{p_2}{100}.
  • …\ldots
  • If XX is at least UkU_k, the tax from the earlier parts stays the same, and the remainder X−UkX - U_k is taxed at pk+1p_{k+1} percent. The total tax is U1⋅p1100+(U2−U1)⋅p2100+…+(X−Uk)⋅pk+1100U_1 \cdot \frac{p_1}{100} + (U_2 - U_1) \cdot \frac{p_2}{100} + \ldots + (X - U_k) \cdot \frac{p_{k+1}}{100}.

Given income XX, compute the income tax.

Input

The first line contains two integers XX and kk (0≤X≤1090 \le X \le 10^9, 1≤k≤1001 \le k \le 100). The second line contains kk integers U1,U2,…,UkU_1, U_2, \ldots, U_k (1≤U1<U2<…<Uk≤1091 \le U_1 < U_2 < \ldots < U_k \le 10^9). The third line contains k+1k + 1 integers p1,p2,…,pk,pk+1p_1, p_2, \ldots, p_k, p_{k+1} (0≤p1≤p2≤…≤pk+1≤1000 \le p_1 \le p_2 \le \ldots \le p_{k+1} \le 100).

Output

Print the income tax that an honest citizen of Flatland must pay after earning XX units of Flatland currency, on a single line. Print the answer with exactly two digits after the decimal point.

Examples1

  1. Example 1

    Input
    1500 2
    1000 2000
    10 20 30
    
    Expected output
    200.00