#include "bits/stdc++.h"
#define INF 1e+9

using namespace std;

int main(void){
  int N, M, D[1010], C[1010], dp[1010][1010];
  scanf("%d %d", &N, &M);

  for(int i = 0; i < N; ++i){
    scanf("%d", D + i);
  }
  for(int j = 0; j < M; ++j){
    scanf("%d", C + j);
  }

  for(int i = N - 1; i >= 0; --i){
    for(int j = M; j >= 0; --j){
      int di = (M - j) - (N - i);
      if(di < 0){
        dp[i][j] = INF;
      }else if(di == 0){
        dp[i][j] = dp[i + 1][j + 1] + (D[i] * C[j]);
      }else{
        dp[i][j] = min(dp[i + 1][j + 1] + (D[i] * C[j]), dp[i][j + 1]);
      }
    }
  }

  printf("%d\n", dp[0][0]);

  return 0;
}

