PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000056. Màn ra mắt của hà mã (Hippo Circus)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Màn ra mắt của hà mã (Hippo Circus)

Hippo Circus

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn hippos of heights hih_i entering a gate of height HH. A single hippo takes TaT_a time; two may enter together if the sum of heights is strictly less than HH, taking TdT_d time. At most two hippos enter per trip. Minimize total time.

Input

Line 1: n,H,Ta,Tdn,H,T_a,T_d. Line 2: nn heights hih_i.

Output

Print Case 1: M, where MM is the minimum total time.

Subtasks

  • Subtask 1 (20 points): 1≤n≤51\le n\le 5; 0≤Ta<Td≤100000\le T_a<T_d\le 10000; 1≤hi<1001\le h_i<100; hi<Hh_i<H for every ii; HH is a positive integer.
  • Subtask 2 (30 points): 1≤n≤10001\le n\le 1000; 0≤Ta<Td≤100000\le T_a<T_d\le 10000; 1≤hi<1001\le h_i<100; hi<Hh_i<H for every ii; HH is a positive integer.
  • Subtask 3 (50 points): 1≤n≤1000001\le n\le 100000; 0≤Ta<Td≤100000\le T_a<T_d\le 10000; 1≤hi<1001\le h_i<100; hi<Hh_i<H for every ii; HH is a positive integer.

Examples

Input

3 6 2 3
3 4 2

Output

Case 1: 5

Explanation

The hippos of heights 3 and 2 have total height 5, strictly below 6, so they travel together in time 3; height 4 travels alone in time 2, totaling 5.