# AOJ 0611: Silk Road

# Python3 2018.7.4 bal4u



import sys

from sys import stdin

input = stdin.readline



INF = 0x7fffffff

n, m = list(map(int, input().split()))

d = [int(eval(input())) for i in range(n)]

c = [0] + [int(eval(input())) for i in range(m)]

dp = [[INF for j in range(n+1)] for i in range(2)]

dp[0][0] = 0

for i in range(1, m+1):

	for j in range(n+1): dp[i&1][j] = INF

	for j in range(n+1): dp[i&1][j] = dp[1-(i&1)][j]

	for j in range(n):

		if dp[1-(i&1)][j] != INF:

			dp[i&1][j+1] = min(dp[i&1][j+1], dp[1-(i&1)][j]+c[i]*d[j])

print((dp[i&1][n]))

# AOJ 0611: Silk Road

# Python3 2018.7.4 bal4u



import sys

from sys import stdin

input = stdin.readline



INF = 0x7fffffff

n, m = list(map(int, input().split()))

d = [int(eval(input())) for i in range(n)]

c = [int(eval(input())) for i in range(m)]

dp = [[INF for j in range(n+1)] for i in range(m+1)]

dp[0][0] = 0

for i in range(m):

	for j in range(n+1): dp[i+1][j] = dp[i][j]

	for j in range(n):

		if dp[i][j] != INF:

			dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]+c[i]*d[j])

print((dp[m][n]))

# AOJ 0611: Silk Road
# Python3 2018.7.4 bal4u
import sys
from sys import stdin

input = stdin.readline
INF = 0x7FFFFFFF
n, m = list(map(int, input().split()))
d = [int(eval(input())) for i in range(n)]
c = [0] + [int(eval(input())) for i in range(m)]
dp = [[INF for j in range(n + 1)] for i in range(2)]
dp[0][0] = 0
for i in range(1, m + 1):
    for j in range(n + 1):
        dp[i & 1][j] = INF
    for j in range(n + 1):
        dp[i & 1][j] = dp[1 - (i & 1)][j]
    for j in range(n):
        if dp[1 - (i & 1)][j] != INF:
            dp[i & 1][j + 1] = min(dp[i & 1][j + 1], dp[1 - (i & 1)][j] + c[i] * d[j])
print((dp[i & 1][n]))

# AOJ 0611: Silk Road
# Python3 2018.7.4 bal4u
import sys
from sys import stdin

input = stdin.readline
INF = 0x7FFFFFFF
n, m = list(map(int, input().split()))
d = [int(eval(input())) for i in range(n)]
c = [int(eval(input())) for i in range(m)]
dp = [[INF for j in range(n + 1)] for i in range(m + 1)]
dp[0][0] = 0
for i in range(m):
    for j in range(n + 1):
        dp[i + 1][j] = dp[i][j]
    for j in range(n):
        if dp[i][j] != INF:
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + c[i] * d[j])
print((dp[m][n]))

-c = [0] + [int(eval(input())) for i in range(m)] -dp = [[INF for j in range(n + 1)] for i in range(2)] +c = [int(eval(input())) for i in range(m)] +dp = [[INF for j in range(n + 1)] for i in range(m + 1)] -for i in range(1, m + 1): +for i in range(m): -        dp[i & 1][j] = INF -    for j in range(n + 1): -        dp[i & 1][j] = dp[1 - (i & 1)][j] +        dp[i + 1][j] = dp[i][j] -        if dp[1 - (i & 1)][j] != INF: -            dp[i & 1][j + 1] = min(dp[i & 1][j + 1], dp[1 - (i & 1)][j] + c[i] * d[j]) -print((dp[i & 1][n])) +        if dp[i][j] != INF: +            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + c[i] * d[j]) +print((dp[m][n]))