#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
long long int dp[1001][1001];
int main()
{
	int n, m, d[1001], c[1001],x=0;
	scanf("%d %d", &n, &m);
/*	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <=m; j++)
		{
			dp[i][j] = 100000000000000000;
		}
	}*/
	memset(dp, 0x7f, sizeof(dp));
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &d[i]);
	}
	for (int i = 1; i <= m; i++)
	{
		scanf("%d", &c[i]);
	}
	for (int i = 0; i <=n; i++)
	{
		for (int j = x; j <= m; j++)
		{
			if (i == 0)
				dp[i][j] = 0;
			else
				dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + d[i] * c[j]);
		}
		x++;
	}
	printf("%lld\n", dp[n][m]);
	return 0;
}