//Silk Road AOJ:0611
//???????¨???????????????????
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define min 2100000000
int n,m,d[1000],c[1000],dp[1001][1001];
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++)	dp[i][j]=min;
	}
	for(int i=1;i<=n;i++) cin >> d[i];
	for(int i=1;i<=m;i++) cin >> c[i];
	dp[0][0]=0;
	for(int i=0;i<m;i++){
		for(int j=0;j<=n;j++){
			if(dp[i+1][j]>dp[i][j])	dp[i+1][j]=dp[i][j];
			if(dp[i+1][j+1]>d[j+1]*c[i+1]+dp[i][j]){
				if(j+1<=n)	dp[i+1][j+1]=d[j+1]*c[i+1]+dp[i][j];
			}
		}
	}
	cout << dp[m][n] <<endl;
	return 0;
}