#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int N,M,D[1000],C[1000],dp[1050][1050];
	cin >> N >> M;
	for(int i = 0;i < N;i++) cin >> D[i];
	for(int i = 0;i < M;i++) cin >> C[i];
	for(int i = 0;i <= N;i++){
		for(int j = 0;j <= M;j++){
			dp[i][j] = 10000000000;
		}
	}
	dp[0][0] = 0;
	for(int i = 0;i <= N;i++){
		for(int j = 1;j <= M;j++){
			if(i == 0) dp[i][j] = min(dp[i][j],dp[i][j - 1]);
			dp[i][j] = min(dp[i][j - 1],dp[i - 1][j - 1] + D[i - 1] * C[j - 1]);
		}
	}
	cout << dp[N][M] << endl;
	return 0;
}