#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

int t[100];
int v[100];
int endV[100];
int startV[100];
int tStart[100];
int tEnd[100];

double solve(int a0, int b0, int a1, int b1)
{
    int da = a0 - a1;
    int db = b0 - b1;
    return -(double)db / da;
}

int main()
{
    int N;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> t[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }

    for (int i = N - 1; i >= 0; i--)
    {
        if (i == N - 1)
        {
            endV[i] = 0;
        }
        endV[i] = min(v[i + 1], endV[i + 1] + t[i + 1]);
    }

    for (int i = 0; i < N; i++)
    {
        if (i == 0)
        {
            startV[i] = 0;
        }
        startV[i] = min(v[i - 1], startV[i - 1] + t[i - 1]);
    }

    for (int i = 0; i < N; i++)
    {
        if (i == 0)
        {
            tStart[i] = 0;
            tEnd[i] = t[i];
            continue;
        }
        tStart[i] = tEnd[i - 1];
        tEnd[i] = tStart[i] + t[i];
    }

    vector<pair<double, double>> solutions;
    solutions.push_back(make_pair(0, 0));

    for (int i = 0; i < N; i++)
    {
        double solution = solve(0, v[i], 1, startV[i]);

        if (solution <= 0)
        {
            // in case of -
            double solution = solve(0, v[i], -1, endV[i] + t[i]);
            if (solution <= 0)
            {
                solutions.push_back(make_pair(tEnd[i], endV[i]));
            }
            else if (solution >= t[i])
            {
                solutions.push_back(make_pair(tEnd[i], v[i]));
            }
            else
            {
                solutions.push_back(make_pair(tStart[i] + solution, v[i]));
                solutions.push_back(make_pair(tEnd[i], endV[i]));
            }
        }
        else if (solution >= t[i])
        {
            // in case of /
            double solution = solve(1, startV[i], -1, endV[i] + t[i]);
            if (solution <= 0)
            {
                solutions.push_back(make_pair(tEnd[i], endV[i]));
            }
            else if (solution >= t[i])
            {
                solutions.push_back(make_pair(tEnd[i], startV[i] + t[i]));
            }
            else
            {
                solutions.push_back(make_pair(tStart[i] + solution, startV[i] + solution));
                solutions.push_back(make_pair(tEnd[i], endV[i]));
            }
        }
        else
        {
            double mid = solution;
            {
                // in case of /
                double solution = solve(1, startV[i], -1, endV[i] + t[i]);
                if (solution <= 0)
                {
                    solutions.push_back(make_pair(tStart[i] + mid, endV[i] + t[i] - mid));
                }
                else if (solution >= mid)
                {
                    solutions.push_back(make_pair(tStart[i] + mid, startV[i] + mid));
                }
                else
                {
                    solutions.push_back(make_pair(tStart[i] + solution, startV[i] + solution));
                    solutions.push_back(make_pair(tStart[i] + mid, endV[i] + t[i] - mid));
                }
            }
            {
                // in case of -
                double solution = solve(0, v[i], -1, endV[i] + t[i]);
                if (solution <= mid)
                {
                    solutions.push_back(make_pair(tEnd[i], endV[i]));
                }
                else if (solution >= t[i])
                {
                    solutions.push_back(make_pair(tEnd[i], v[i]));
                }
                else
                {
                    solutions.push_back(make_pair(tStart[i] + solution, v[i]));
                    solutions.push_back(make_pair(tEnd[i], endV[i]));
                }
            }
        }
    }

    double result = 0;
    for (int i = 0; i < solutions.size() - 1; i++)
    {
        double h = solutions[i + 1].second + solutions[i].second;
        double w = solutions[i + 1].first - solutions[i].first;
        double area = h * w / 2;
        result += area;
    }

    cout << fixed << result << endl;

    return 0;
}

Measured memory_bytes: 256