Logo
(追記) (追記ここまで)

31686번 - Rolete 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB31131257.143%

문제

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 $n$ blinds in his room, where the $i$-th one is lowered by $a_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 $t$ seconds to raise the blind by 1ドル$ 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 1ドル$ centimeter in s seconds. If $r$ blinds have already been risen to the top that slows down the system. Then it will take $s + k \cdot r$ seconds for all the remaining blinds to rise by 1ドル$ 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 $q$ questions: What is the minimum time you need to raise the blinds so that they are all lowered by at most $h$ 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 $n,ドル $t,ドル $s$ and $k$ (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 $n$ integers $a_i$ (0ドル ≤ a_i ≤ 10^5$), the initial state of blinds.

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

The fourth line contains $q$ integers $h_i$ (0ドル ≤ h_i ≤ 10^5$), required maximal blind height.

출력

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

제한

서브태스크

번호배점제한
116

$n, q, a_i , h_i ≤ 100$

226

$k = 0$

332

$q = 1$

436

No additional constraints.

예제 입력 1

3 2 5 1
2 2 4
3
2 0 1

예제 출력 1

4 14 9

To have all blinds lowered by at most 2ドル$ centimeters, Luka needs to manually raise the third blind by 2ドル$ centimeters. The quickest way to do this is to raise it manually. This will take him 4ドル$ seconds.

예제 입력 2

2 3 4 0
3 1
3
3 2 0

예제 출력 2

0 3 10

If all blinds need to be fully raised, Luka can first raise the third blind by 2ドル$ centimeters manually. Now he can press the button and let the blinds rise in parallel by 2ドル$ centimeters. In total, that will take 4ドル + 10 = 14$ seconds.

예제 입력 3

4 3 10 3
2 4 5 6
3
4 3 0

예제 출력 3

9 18 47

Similarly, if the blinds need to be lowered by at most 1ドル$ centimeter, Luka will first raise the third blind by 2ドル$ centimeters, and then raise all blinds together by 1ドル$ centimeter. The total time for raising will be 9ドル$ seconds.

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2023/2024 > Contest #5 4번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /