Under construction

Still being built. Things may change

Life

Time limit2sMemory limit1024 MB

Summary
For each prefix of length n, find the minimum total of chosen values when each pick shifts all later A and B values by +U or -D.
Level

Hard8 of 10

Topics
Dynamic programming, Greedy
Solved
No attempts yet

Problem

You are given two arrays AA and BB of NN integers each, and two integers UU and DD. The ii-th elements of AA and BB are AiA_i and BiB_i.

Define f(n)f(n) as follows.

  • For i=1,2,⋯ ,ni = 1, 2, \cdots, n, in order, do the following.
    1. Choose one of AiA_i and BiB_i.
    2. For every jj with i<j≤ni < j \le n, if you chose AiA_i, the values of AjA_j and BjB_j each increase by UU. If you chose BiB_i, the values of AjA_j and BjB_j each decrease by DD.

f(n)f(n) is the minimum sum of the chosen numbers over the 2n2^n ways to choose.

For every integer nn with 1≤n≤N1 \le n \le N, find f(n)f(n).

Input

The first line contains NN, UU, and DD, separated by spaces. (1≤N≤300 0001 \le N \le 300\,000, 1≤U,D≤1061 \le U, D \le 10^6)

The second line contains A1,A2,⋯ ,ANA_1, A_2, \cdots, A_N, separated by spaces. (0≤Ai≤1060 \le A_i \le 10^6)

The third line contains B1,B2,⋯ ,BNB_1, B_2, \cdots, B_N, separated by spaces. (0≤Bi≤1060 \le B_i \le 10^6)

Output

Print NN lines. On the nn-th line, print f(n)f(n).

Examples1

  1. Example 1

    Input
    5 2 3
    4 8 2 8 1
    11 5 14 8 19
    
    Expected output
    4
    11
    9
    13
    7