Help Rohit Problem

Help Rohit

 

Description :-

Rohit live in Janakpuri and uses public transport to go to college that is on Dwarka. The transport from Janakpuri to Dwarka is of two types: cabs and rickshaws. The city has n rickshaws and m cabs, the rickshaws are numbered by integers from 1 to n, the cabs are numbered by integers from 1 to m.

Public transport is not free. There are 4 types of tickets:

A ticket for one ride on some rickshaw or cab. It costs c1 rupees;
A ticket for an unlimited number of rides on some rickshaw or on some cab. It costs c2 rupees;
A ticket for an unlimited number of rides on all rickshaws or all cabs. It costs c3 rupees;
A ticket for an unlimited number of rides on all rickshaws and cabs. It costs c4 rupees.

Rohit knows for sure the number of rides he is going to make and the transport he is going to use. He asked you for help to find the minimum sum of rupees he will have to spend on the tickets.

 

Input Format :-

Each Test case has 4 lines which are as follows:

The first line contains four integers c1, c2, c3, c4 (1 ≤ c1, c2, c3, c4 ≤ 1000) — the costs of the tickets. The second line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of rickshaws and cabs Rohit is going to use. The third line contains n integers ai (0 ≤ ai ≤ 1000) — the number of times Rohit is going to use the rickshaw number i. The fourth line contains m integers bi (0 ≤ bi ≤ 1000) — the number of times Rohit is going to use the cab number i.

 

Output Format :-

Print a single number — the minimum sum of rupees Rohit will have to spend on the tickets.

 

Sample Input :-

3

1 2 3 4

2 2

1 1

2 3

14 17 20 25

3 2

12 11 10

25 30

2 3 5 19

3 2

1 5 4

6 8 9

 

Sample Output :-

4
25
10

 

solution button

 

Comments

No comment yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact us





Scroll Up