#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MP make_pair
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int d[1000], c[1000];
int dp[1001][1001];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, m)scanf("%d", &c[i]);
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 1; i <= m; i++)for (int j = 0; j <= n; j++) {
		if (!j)dp[i][j] = dp[i - 1][j];
		else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + c[i - 1] * d[j - 1]);
	}
	printf("%d\n", dp[m][n]);
}