Yuki with playf
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Today HNU is holding the hucpc2021. Yuki is very excited and wants to attend this amazing contest. Unfortunately, the contest needs a team to participate. Yuki can register a team only himself. However, yuki is too weak and he does not want to compete with other teams only himself. Therefore poor yuki asks volunteers for help. After the volunteer's introduction, yuki knows a genius person called playf, who already registered a team with a single person. Poor yuki finds playf and tells playf about his embarrassing situation. Playf is a generous and kind-hearted man. He is so glad and decides to let yuki join his team. After 5 hours of exciting competition, there is no doubt that genius playf wins the champion in hucpc2021! Yuki is a really lucky dog because he has done nothing in the whole competition. Poor yuki is so curious why playf so strong and asks playf for some life experiences. playf is a very generous man so he tells yuki a lot. After that, yuki knows that playf is not only a genius but also a city traveller, and yuki is very interested in playf's city travel experiences. The most interesting city travel yuki think is following:
Long long ago, playf travelled in a country with cities and he got  diamonds when he travelled around these cities. Playf was such generous and kind-hearted man, so he wanted to donate the diamonds for helped as much as people he could. After playf investigated, he found that -th diamond had a price p_j and one unit price could buy c_i bread in -th city, which was mean -th diamond in -th city could exchange  bread, so playf decided to sold these diamonds to bought bread, then he distributed all the bread to people. But there were some rules in this country, for protected trading environment, every traveller at most sold one diamond in a city and the bread had bought in a city could not bring to other cities, for equity and satisfied three meals a day of one person, the number of bread distributed to each person should same and at least three, in other words, there are  bread can distribute to y guys if  and .And playf wanted to distribute all the bread exchanged without leave.

Playf is a genius and quickly found the solution to help as much as people, which is mean the total number of people was distributed in each city is maximized. But playf does not tell the actually number to yuki, poor yuki wants to know the number, can you help yuki?

输入描述:

First line contains two integers , are mentioned in the description.

Second line contains  integersc_1,c_2...c_n, are mentioned in the description.

Thirdline contains  integers p_1,p_2,...p_M,are mentioned in the description.

输出描述:

A line contains an integer indicated the maximum number of people was distributed.

示例1

输入

复制
2 4
2 2
2 1 3 2

输出

复制
3
示例2

输入

复制
2 4
1 1
2 1 2 1

输出

复制
0
示例3

输入

复制
1 1
1000000
1000000

输出

复制
250000000000