This page is still under construction.

Parts of this page are still being built. What you see may change.

Tax System

Interview

Time limit1sMemory limit1024 MB

Summary
Each client's income is taxed through N progressive brackets with given widths and rates; compute the total tax for M clients, printed to two decimals.
Level

Medium5 of 10

Topics
Prefix sum, Binary search, Math, Implementation
Solved
No attempts yet

Problem

The country of Umeerika recently decided to switch to a progressive income tax system consisting of NN tax brackets (numbered 1…N1 \ldots N). Each bracket ii has a taxable income width CiC_i and a tax rate PiP_i (in percent). Tax is charged as follows: a person pays P1P_1 percent on the first C1C_1 euros of their annual income, P2P_2 percent on the next C2C_2 euros, and so on. Since CN=∞C_N = \infty, the entire income is taxed.

Write a program that, for MM clients, computes the total tax owed on each client's income.

Input

The first line contains the number of tax brackets NN (1≤N≤1051 \le N \le 10^5). The second line contains N−1N-1 integers CiC_i (1≤Ci≤1091 \le C_i \le 10^9); the width of the last bracket, CN=∞C_N = \infty, is not given in the input (when N=1N = 1 this line is empty). The third line contains NN integers PiP_i (0≤Pi≤1000 \le P_i \le 100). The fourth line contains the number of clients MM (1≤M≤1051 \le M \le 10^5). Each of the next MM lines contains one integer SiS_i (0≤Si≤1090 \le S_i \le 10^9).

Output

Output exactly MM lines. On the ii-th line, print the total tax owed on income SiS_i. Print each amount with exactly two digits after the decimal point.

Examples2

  1. Example 1

    Input
    4
    10000 20000 40000
    0 10 20 30
    3
    9000
    35000
    1000000
    
    Expected output
    0.00
    3000.00
    289000.00
    
  2. Example 2

    Input
    3
    20000 40000
    20 50 10
    3
    40000
    1000000
    1
    
    Expected output
    14000.00
    118000.00
    0.20