#include using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) using ll = long long; int main(){ int n; cin >> n; vector a(n), r(n), b(n+1), id(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> r[i]; b[0] = 0; rep(i,n) b[i+1] = a[i]; sort(b.begin(),b.end()); b.erase(unique(b.begin(),b.end()),b.end()); int m = b.size(); map mp; rep(i,m) mp[b[i]] = i; rep(i,n) id[i] = mp[a[i]]; vector> dp(m+1,vector(n+1)); rep(j,id[0]) dp[j][0] = 1.0; for(int j = id[0]; j < m; j++) dp[j][1] = 1.0; double ans = 0.0; rep(i,n) { for(int j = 1; j <= m; j++) ans += dp[j-1][0]*r[i]*(b[j]-b[j-1])/2; vector> dpn(m+1,vector(n+1)); if(i == n-1) break; rep(j,m+1) { int nk = 0; if(j >= id[i+1]) nk++; dpn[j][nk] += dp[j][0]; } rep(j,m+1) for(int k = 1; k <= n; k++) { for(int df = -1; df <= 0; df++) { int nk = k+df; if(j >= id[i+1]) nk++; if(nk >= 0 and nk <= n) dpn[j][nk] += dp[j][k]/2.0; } } swap(dp,dpn); } cout << fixed << setprecision(12) << ans << endl; return 0; }