PivotOJ

Rolete

시간 제한: 2000ms메모리 제한: 1024MB출처: COCI 2023-2024BOJ 31686

문제

One Saturday Luka woke up from an afternoon nap and remembered: today is COCI! There was only one thing that he needed to do before the contest: raise the blinds.

Luka has nn blinds in his room, where the ii-th one is lowered by aia_i centimeters from the top of the window. He can raise the blinds in two ways:

  • He can start lifting any singular blind manually. With this method, it takes him tt seconds to raise the blind by 11 centimeter.
  • He can press a button, which starts raising all blinds parallel at the same speed.

The speed at which the blinds are raised with a button is defined as follows: If all blinds are still rising, each will rise by 11 centimeter in s seconds. If rr blinds have already been risen to the top that slows down the system. Then it will take s+krs + k \cdot r seconds for all the remaining blinds to rise by 11 centimeter.

COCI is about to start, and Luka wants to raise his blinds as soon as possible. Meanwhile, his brother Marin entered the room and asked him qq questions: What is the minimum time you need to raise the blinds so that they are all lowered by at most hh centimeters? Marin is interested in the answer for each question considering the initial state of the blinds.

They realized that there is not enough time to think about it before COCI. Fortunately, the problem has just appeared here as well! Help them solve it!

Note: Luka will always raise the blind by an integer value of centimeters.

입력

The first line contains integers nn, tt, ss and kk (1 ≤ n, t, s ≤ 10^5, 0 ≤ k ≤ 10^5), the number of blinds, the time required to raise a blind manually, the time required to raise a blind with a button and the slowing factor of parallel raising.

The second line contains nn integers aia_i (0 ≤ a_i ≤ 10^5), the initial state of blinds.

The third line contains integer qq (1 ≤ q ≤ 10^5), number of questions.

The fourth line contains qq integers hih_i (0 ≤ h_i ≤ 10^5), required maximal blind height.

출력

In first and only line print qq numbers, ii-th of them is minimum time for raising the blinds such that they are lowered by at most hih_i centimeters.

예제

예제 1

입력
3 2 5 1
2 2 4
3
2 0 1
출력
4 14 9

예제 2

입력
2 3 4 0
3 1
3
3 2 0
출력
0 3 10

예제 3

입력
4 3 10 3
2 4 5 6
3
4 3 0
출력
9 18 47
코드를 제출하려면 로그인하세요.