0
点赞
收藏
分享

微信扫一扫

ZCMU—1309

小暴龙要抱抱 2022-09-07 阅读 83


1309: Vasya and Public Transport


Time Limit: 1 Sec   Memory Limit: 128 MB

[​Submit​​][​Status​​][​Web Board​​]


Description


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 c1 burles;
2. A ticket for an unlimited number of rides on some bus or on some trolley. It costs c2 burles;
3.A ticket for an unlimited number of rides on all buses or all trolleys. It costs c3 burles;
4.A ticket for an unlimited number of rides on all buses and trolleys. It costs c4 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.


Input


The first line contains four integers c1, c2, c3, c4 (1 ≤ c1, c2, c3, c4 ≤ 1000)

The second line contains two integers n and m (1 ≤ n, m ≤ 1000)

The third line contains n integers ai (0 ≤ ai ≤ 1000) — the number of times Vasya is going to use the bus number i.

The fourth line contains m integers bi (0 ≤ bi ≤ 1000) — the number of times Vasya is going to use the trolley number i.


Output


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


Sample Input


1 3 7  19


2 3


2 5


4 4 4


4 3 2 1


1 3


7 98


1 2 3


100 100 8 100


3 5


7 94 12


100 1 47 0 42


Sample Output


12


1


16


【分析】


题目的意思是现在有两种交通工具,由于乘坐次数不同可以买不同的票,有坐一次的,坐多次的,同时也可以买一种在不同交通工具之中任意乘坐的票。现在已经知道每种交通工具乘坐次数,问最小花费是多少。


感觉难度就在读题上。。。而且读题也不是很难。。直接算就好了,记得多次读取就好


【代码】


#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
int a[10];
while (~scanf("%d",&a[0]))
{
int m,n;
int ans1=0;
int ans2=0;
for(int i=1;i<4;i++) scanf("%d",&a[i]);
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
int x;scanf("%d",&x);
ans1+=min(a[0]*x,a[1]);
}
for(int i=0;i<m;i++)
{
int x;scanf("%d",&x);
ans2+=min(a[0]*x,a[1]);
}
ans1=min(ans1,a[2]);
ans2=min(ans2,a[2]);
printf("%d\n",min(ans1+ans2,a[3]));
}
return 0;
}



举报

相关推荐

0 条评论