301876: CF355B. Vasya and Public Transport

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Vasya and Public Transport

题意翻译

``` Vasya 所在城市的交通工具有两种类型:手推车和公共汽车。 其中公共汽车有 n 辆,手推车有 m 辆。 公共汽车的编号为 a1,a2,..an,手推车的编号为 b1,b2,..bn 交通工具的门票有 4 种类型: 1: 乘坐某辆公共汽车或手推车的车票, 它需要 c1 元 2: 在某辆公共汽车或某些手推车上无限次乘坐的车票, 它需要 c2 元 3: 所有公共汽车或所有手推车上无限次乘坐的车票, 它需要 c3 元 4: 所有公共汽车和手推车上无限次乘坐的车票, 它需要c4 元。 输入格式: 第一行包含 4 个整数: c1,c2,c3,c4 第二行包含 2 个整数: n,m 第三行包含 n 个整数: a1..an 第四行包含 m 个整数: b1..bm 输出格式: 一个整数,即 Vasya 所要支付的最少钱数 数据规模: 1 <= c1,c2,c3,c4,n,m <= 1000 0 <= ai,bi <= 1000 ```

题目描述

Vasya often uses public transport. The transport in the city is of two types: trolleys and buses. The city has $ n $ buses and $ m $ trolleys, the buses are numbered by integers from $ 1 $ to $ n $ , the trolleys are numbered by integers from $ 1 $ to $ m $ . Public transport is not free. There are 4 types of tickets: 1. A ticket for one ride on some bus or trolley. It costs $ c_{1} $ burles; 2. A ticket for an unlimited number of rides on some bus or on some trolley. It costs $ c_{2} $ burles; 3. A ticket for an unlimited number of rides on all buses or all trolleys. It costs $ c_{3} $ burles; 4. A ticket for an unlimited number of rides on all buses and trolleys. It costs $ c_{4} $ burles. Vasya 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 burles he will have to spend on the tickets.

输入输出格式

输入格式


The first line contains four integers $ c_{1},c_{2},c_{3},c_{4} $ $ (1<=c_{1},c_{2},c_{3},c_{4}<=1000) $ — the costs of the tickets. The second line contains two integers $ n $ and $ m $ $ (1<=n,m<=1000) $ — the number of buses and trolleys Vasya is going to use. The third line contains $ n $ integers $ a_{i} $ $ (0<=a_{i}<=1000) $ — the number of times Vasya is going to use the bus number $ i $ . The fourth line contains $ m $ integers $ b_{i} $ $ (0<=b_{i}<=1000) $ — the number of times Vasya is going to use the trolley number $ i $ .

输出格式


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

输入输出样例

输入样例 #1

1 3 7 19
2 3
2 5
4 4 4

输出样例 #1

12

输入样例 #2

4 3 2 1
1 3
798
1 2 3

输出样例 #2

1

输入样例 #3

100 100 8 100
3 5
7 94 12
100 1 47 0 42

输出样例 #3

16

说明

In the first sample the profitable strategy is to buy two tickets of the first type (for the first bus), one ticket of the second type (for the second bus) and one ticket of the third type (for all trolleys). It totals to $ (2·1)+3+7=12 $ burles. In the second sample the profitable strategy is to buy one ticket of the fourth type. In the third sample the profitable strategy is to buy two tickets of the third type: for all buses and for all trolleys.

Input

题意翻译

``` Vasya 所在城市的交通工具有两种类型:手推车和公共汽车。 其中公共汽车有 n 辆,手推车有 m 辆。 公共汽车的编号为 a1,a2,..an,手推车的编号为 b1,b2,..bn 交通工具的门票有 4 种类型: 1: 乘坐某辆公共汽车或手推车的车票, 它需要 c1 元 2: 在某辆公共汽车或某些手推车上无限次乘坐的车票, 它需要 c2 元 3: 所有公共汽车或所有手推车上无限次乘坐的车票, 它需要 c3 元 4: 所有公共汽车和手推车上无限次乘坐的车票, 它需要c4 元。 输入格式: 第一行包含 4 个整数: c1,c2,c3,c4 第二行包含 2 个整数: n,m 第三行包含 n 个整数: a1..an 第四行包含 m 个整数: b1..bm 输出格式: 一个整数,即 Vasya 所要支付的最少钱数 数据规模: 1 <= c1,c2,c3,c4,n,m <= 1000 0 <= ai,bi <= 1000 ```

加入题单

算法标签: