#586. 「Nowcoder多校 2019 Day4」sequence

「Nowcoder多校 2019 Day4」sequence

当前没有测试数据。

题目描述

Your are given two sequences a1n a1…n and b1n b1…n .You need to answer $ max_{1 \le l \le r \le n} \{min(a_{l \dots r}) \times sum(b_{l \dots r})\} $。

Where min(a) means the minimal value of every element of sequence a, sum(a) means the sum of every element of sequence a .

输入格式

The first line contains an integer n .

The second line contains n integers meaning a1n a1…n .

The third line contains n integers meaning b1n b1…n . The first line contains an integer n .

The second line contains n integers meaning a1n a1…n .

The third line contains n integers meaning b1n b1…n .

输出格式

An integer meaning the answer.

样例

样例输入 1

3
1 -1 1
1 2 3

样例输出 1

3

数据范围与提示

For all test datas, 1n3×106 1≤n≤3×10^6 ,106ai,bi106 -10^6​≤ai,bi​≤10^6 .