In the year 2168, AtCoder Inc., which is much larger than now, is starting a limited express train service called AtCoder Express.
In the plan developed by the president Takahashi, the trains will run as follows:
 - A train will run for (t_1 + t_2 + t_3 + ... + t_N) seconds.
 - In the first t_1 seconds, a train must run at a speed of at most v_1 m/s (meters per second). Similarly, in the subsequent t_2 seconds, a train must run at a speed of at most v_2 m/s, and so on.
According to the specifications of the trains, the acceleration of a train must be always within ±1m/s^2. Additionally, a train must stop at the beginning and the end of the run.
Find the maximum possible distance that a train can cover in the run.

-----Constraints-----
 - 1 \leq N \leq 100
 - 1 \leq t_i \leq 200
 - 1 \leq v_i \leq 100
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
t_1 t_2 t_3 … t_N
v_1 v_2 v_3 … v_N

-----Output-----
Print the maximum possible that a train can cover in the run.

Output is considered correct if its absolute difference from the judge's output is at most 10^{-3}.

-----Sample Input-----
1
100
30

-----Sample Output-----
2100.000000000000000


The maximum distance is achieved when a train runs as follows:
 - In the first 30 seconds, it accelerates at a rate of 1m/s^2, covering 450 meters.
 - In the subsequent 40 seconds, it maintains the velocity of 30m/s, covering 1200 meters.
 - In the last 30 seconds, it decelerates at the acceleration of -1m/s^2, covering 450 meters.
The total distance covered is 450 + 1200 + 450 = 2100 meters.

Difficulty: interview

Starter code:

Solutions:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    t = list(map(lambda x: int(x) * 2, input().split()))
    v = list(map(float, input().split())) + [0]

    for i in range(1, N):
        t[i] += t[i-1]
    t += [t[-1]]
    vnow = [0.0] * (t[-1] + 1)
    vr = [0.0] * (t[-1] + 1)
    r = 0
    for i in range(1, len(vr)):
        if i < t[r]:
            vr[i] = v[r]
        elif i == t[r]:
            vr[i] = min(v[r], v[r+1])
            r += 1
        vnow[i] = min(vnow[i-1] + 0.5, vr[i])
    for i in range(len(vr)-2, -1, -1):
        vnow[i] = min(vnow[i], vnow[i+1] + 0.5)
    
    print(sum(vnow) / 2)

def __starting_point():
    main()
__starting_point()

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    t = list(map(int, input().split()))
    v = list(map(int, input().split()))
    
    
    length = sum(t)*2
    
    dp = [0]*(length+1)
    border = v[0]
    count = t[0]*2
    index = 0
    for i in range(length):
        dp[i+1] = min(dp[i]+0.5, border)
        count -= 1
        if i == length-1:
            break
        if count == 0:
            index += 1
            border = v[index]
            count = t[index]*2
    
    dp[length] = 0
    border = v[n-1]
    count = t[n-1]*2
    index = n-1
    for i in range(length, 0, -1):
        dp[i-1] = min([dp[i]+0.5, border, dp[i-1]])
        count -= 1
        if i == 0:
            break
        if count == 0:
            index -= 1
            border = v[index]
            count = t[index]*2
    
    ans = 0
    for i in range(length):
        ans += (dp[i]+dp[i+1])/4
        
    print(ans)
    
    
    
    
def __starting_point():
    main()

__starting_point()

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))


MAX_V = [0]
for t, v in zip(T, V):
    MAX_V[-1] = min(MAX_V[-1], v)
    for ti in range(t * 2):
        MAX_V.append(v)


N = len(MAX_V)
Feasible_V = [0] * N
for i in range(N - 1):
    Feasible_V[i + 1] = min(Feasible_V[i] + 0.5, MAX_V[i + 1])

Feasible_V[-1] = 0
for i in reversed(list(range(1, N))):
    Feasible_V[i - 1] = min(Feasible_V[i - 1], Feasible_V[i] + 0.5)


ans = 0
for i in range(N - 1):
    x1, x2 = Feasible_V[i], Feasible_V[i + 1]
    ans += (x1 + x2) * 0.5 / 2

print(ans)


def calc_vt(v,t):
    vt = [0]*(sum(t)*2+1)
    t_sum = 0
    for ti,vi in zip(t,v):
        for i in range(ti*2):
            vt[t_sum + 1 + i] = min(vt[t_sum + i] + 0.5,vi)
        t_sum += ti*2
    return vt

n = input().split()
tn = list(map(int,input().split()))
vn = list(map(int,input().split()))

vt_l = calc_vt(vn,tn)
vt_r = calc_vt(vn[::-1],tn[::-1])[::-1]

vt_lr = [min(vl,vr) for vl,vr in zip(vt_l,vt_r)]

print((sum((a+b)*0.5/2 for a,b in zip(vt_lr,vt_lr[1:]))))


N = int(input())
T = list([int(t) * 10 for t in input().split()])
V = list(map(int, input().split())) + [0]
R = sum(T)

maxSpeed = [10**18] * (R + 1)
maxSpeed[0] = 0
maxSpeed[R] = 0
now = 0
for i, t in enumerate(T):
    now += t
    maxSpeed[now] = min(V[i], V[i + 1])

now = 0
for v, t in zip(V, T):
    for i in range(t + 1):
        maxSpeed[now + i] = min(maxSpeed[now + i], v)
    now += t

for t in range(1, R + 1):
    maxSpeed[t] = min(maxSpeed[t], maxSpeed[t - 1] + 0.1)
for t in range(R)[::-1]:
    maxSpeed[t] = min(maxSpeed[t], maxSpeed[t + 1] + 0.1)

base = 0
upper = 0
for v1, v2 in zip(maxSpeed, maxSpeed[1:]):
    base += min(v1, v2)
    upper += abs(v1 - v2)
ans = base + upper / 2
print((ans / 10))


def atcoder_express(N: int, T: list, V: list)->float:
    MAXT = sum(T)
    graph = [0] * (2*MAXT + 1)

    T = [0, 0] + T + [0]
    for i in range(N+2):
        T[i+1] += T[i]

    V = [0] + V + [0]

    conditions = []
    for i in range(N+2):
        v, l, r = V[i], T[i], T[i+1]
        conditions.append((l, r, v))

    total = 0.0
    prev_v = 0.0
    for t in range(MAXT*2+1):
        min_v = float('inf')
        x = t / 2
        for l, r, v in conditions:
            if x < l:
                min_v = min(min_v, v + (l - x))
            elif r < x:
                min_v = min(min_v, v + (x - r))
            else:
                min_v = min(min_v, v)
        total += (prev_v + min_v) * 0.5 / 2
        prev_v = min_v

    return total


def __starting_point():
    N = int(input())
    T = [int(s) for s in input().split()]
    V = [int(s) for s in input().split()]
    ans = atcoder_express(N, T, V)
    print(ans)

__starting_point()

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
FT = sum(T)*2+1
import numpy as np
limit = []
cumt = 0
for n in range(2+N):
    if n==0:
        lis = [(0.5)*i for i in range(FT)]
    elif n==1:
        lis = [(0.5)*i for i in range(FT)][::-1]
    else:
        t = T[n-2]
        v = V[n-2]
        lis = [v+cumt//2-0.5*i for i in range(cumt)] + [v for _ in range(t*2)] + [v+i*0.5 for i in range(FT-cumt-t*2)]
        cumt += t*2
    limit.append(lis)
limit = np.min(np.array(limit), axis=0)
ans = 0
for i in range(FT-1):
    ans += (limit[i+1]+limit[i])*0.25
print(ans)

N = int(input())

t = [int(x) for x in input().split()]
vSection = [int(x) for x in input().split()]

vPoint = [0]
for i in range(1, N):
	vPoint.append(min(vSection[i - 1], vSection[i]))
vPoint.append(0)

for i in reversed(range(1, N + 1)):
	if t[i - 1] < vPoint[i - 1] - vPoint[i]:
		vPoint[i - 1] = t[i - 1] + vPoint[i]


ans = 0
VE = 0
for i in range(N):
	VS = VE
	if VS + t[i] <= vPoint[i + 1]:
		VE = VS + t[i]
		ans += VS * t[i] + t[i] ** 2 / 2
	else:
		VE = vPoint[i + 1]
		sumT = sum(t[:i])
		a = VS - (0 if i == 0 else sumT)
		b = VE + sum(t[:i+1])
		y = (a + b) / 2
		if y >= vSection[i]:
			t1 = vSection[i] - VS
			t2 = vSection[i] - VE
			ans += VS * t1 + t1 ** 2 / 2 + vSection[i] * (t[i] - t1 - t2) + VE * t2 + t2 ** 2 / 2
		else:
			x = y - a
			ans += VS * (x - sumT) + (x - sumT) ** 2 / 2 + VE * (t[i] - (x - sumT)) + (t[i] - (x - sumT)) ** 2 / 2
			
print(ans)

n = int(input())
t = list(map(float, input().split()))
v = list(map(float, input().split()))

for i in range(n):
    t[i] *= 2.0
    v[i] *= 2.0

v.append(0.0)

for i in range(n - 1, -1, -1):
    v[i] = min(v[i], v[i + 1] + t[i])

for i in range(1, n):
    t[i] += t[i - 1]

ans = 0.0
speed = 0.0
k = 0
st = int(t[n - 1] + 0.1)

for i in range(st):
    if i >= t[k]:
        k += 1
    
    ans += speed

    limit = min(v[k], v[k + 1] + t[k] - i - 1)
    if speed < limit:
        ans += 0.5
        speed += 1.0
    elif speed > limit:
        ans -= 0.5
        speed -= 1.0

ans /= 4.0

print(ans)

# 19/4/17再戦
# -x + a = x + b だと x = (sum)/2で~.5になる可能性がある
# う～～～ん

n = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
sum_t = sum(ts)
n = 2*sum_t+1
max_v = [float("inf")]*n
# 0から右上、-1から左上
for i in range(n):
    max_v[i] = min(i/2, (sum_t-i/2))

# intでtimeは管理するか...
# 0→0, 0.5→1, 1→2 ... i/2→i
t_cnt = 0
for t, v in zip(ts, vs):
    for j in range(2*t+1):
        max_v[t_cnt + j] = min(max_v[t_cnt + j], v)

    # 左側に伸ばしていく
    left = t_cnt
    while left >= 0:
        v_left = v + (t_cnt - left)/2
        if max_v[left] < v_left:
            break
        max_v[left] = v_left
        left -= 1
    # 右側に伸ばしていく
    t_cnt += 2*t
    right = t_cnt
    while right < n:
        v_right = v + (right - t_cnt)/2
        if max_v[right] < v_right:
            break
        max_v[right] = v_right
        right += 1

#print(max_v)
ans = sum(max_v) - (max_v[0]+max_v[-1])/2
print(ans/2)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(input())
T = [0] + list(map(int, input().split()))
V = [0] + list(map(int, input().split()))

max_speed_from_left = [0] * (N + 1)
max_speed_from_right = [0] * (N + 1)

for i in range(1, N):
    start = max_speed_from_left[i - 1]
    max_speed_from_left[i] = min(start + T[i], V[i], V[i + 1])

for i in range(N - 1, 0, -1):
    start = max_speed_from_right[i + 1]
    max_speed_from_right[i] = min(start + T[i + 1], V[i], V[i + 1])

speed = [min(x, y) for x, y in zip(max_speed_from_left, max_speed_from_right)]

def dist(left_speed, right_speed, t, v):
    x = (v - left_speed) + (v - right_speed)
    if x >= t:
        v = (left_speed + right_speed + t) / 2
        x = t
    d = (left_speed + v) * (v - left_speed) / 2
    d += v * (t - x)
    d += (right_speed + v) * (v - right_speed) / 2
    return d

ans = 0
for i in range(1, N + 1):
    ans += dist(speed[i - 1], speed[i], T[i], V[i])

print (ans)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(input())
T = [0] + list(map(int, input().split()))
V = [0] + list(map(int, input().split()))

left = [0] * (N + 1)
right = [0] * (N + 1)

for i in range(1, N):
    start = left[i - 1]
    left[i] = min(start + T[i], V[i], V[i + 1])

for i in range(N - 1, 0, -1):
    start = right[i + 1]
    right[i] = min(start + T[i + 1], V[i], V[i + 1])

total = [min(left[i], right[i]) for i in range(N + 1)]
ans = 0
for i in range(1, N + 1):
    x = (V[i] - total[i - 1]) + (V[i] - total[i])
    if x >= T[i]:
        V[i] = (total[i - 1] + T[i] + total[i]) / 2
        x = T[i]
    d =(total[i - 1] + V[i]) * (V[i] - total[i - 1]) / 2 #台形左側
    d += (total[i] + V[i]) * (V[i] - total[i]) / 2 #台形右側
    d += V[i] * (T[i] - x) #真ん中の定速部分

    ans += d

print (ans)

N = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))
T = sum(t)
ans = [0]

for i in range(N):
  ans[-1] = min(ans[-1],v[i])
  for j in range(t[i]*2):
    ans.append(v[i])

ans[-1] = 0

for i in range(2*T):
  ans[i+1]=min(ans[i]+0.5,ans[i+1])

for i in range(2*T,0,-1):
  ans[i-1]=min(ans[i]+0.5,ans[i-1])

print(sum(ans)/2)

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
L = [0] * (sum(T)*2+1)
R = [0] * (sum(T)*2+1)
xt, xv = 0, 0
for t, v in zip(T, V):
    for tt in range(xt*2+1, (t+xt)*2+1):
        xv += .5
        L[tt] = min(v, xv)
    xt += t
    xv = min(v, xv)
xt, xv = 0, 0
for t, v in zip(T[::-1], V[::-1]):
    for tt in range(xt*2+1, (t+xt)*2+1):
        xv += .5
        R[tt] = min(v, xv)
    xt += t
    xv = min(v, xv)
print(sum(map(min, L, R[::-1]))/2)

n=int(input())
t=[int(a)*2 for a in input().split()]
v=[int(a)*2 for a in input().split()]
ma=[0]*(sum(t)+1)
a=0
for i in range(n):
  for j in range(t[i]):
    a+=1
    ma[a]=min(ma[a-1]+1,v[i])
ma[a]=0
for i in range(n)[::-1]:
  for j in range(t[i]):
    a-=1
    ma[a]=min(ma[a],ma[a+1]+1,v[i])
print((sum(ma[1:])+sum(ma[:-1]))/8)

n,*L=map(int,open(0).read().split())
T,V=L[:n],L[n:]
s=sum(T)
a=[0]
for t,v1,v2 in zip(T,V,V[1:]+[0]):
	a+=[v1]*(2*t-1)+[min(v1,v2)]
for i in range(2*s):
	a[i+1]=min(a[i+1],a[i]+.5)
for i in range(2*s,0,-1):
	a[i-1]=min(a[i-1],a[i]+.5)
print(sum(a)/2)


N = int(input())

t = list(map(int,input().split()))
v = list(map(int,input().split()))

alltime = sum(t)
maxslis = []
rmaxslis = []



spd = 0
ans = 0

for i in range(N):

    for j in range(t[i]):
        maxslis.append(v[i])
        maxslis.append(v[i])
        rmaxslis.append(v[i])


maxslis.reverse()


for i in range(alltime * 2):

    if i == 0:
        able = 0.5
        maxslis[i] = 0

    elif able < maxslis[i]:
        maxslis[i] = able
        able += 0.5

    else:
        able = maxslis[i]

maxslis.reverse()
maxslis.append(0)

#print (maxslis)
dtflag = False

for i in range(alltime * 2 + 1):

    #print (i+1,maxslis[i],spd)

    if spd < maxslis[i]:

        ans += spd * 0.5 + 0.125
        spd += 0.5
        #if spd != maxslis[i]:
            #dtflag = True

    elif spd == maxslis[i]:

        #if dtflag and rmaxslis[i] != maxslis[i]:
            #ans += 0.25
            #print (i+1)
        ans += spd * 0.5
        dtflag = False

    else:
        ans += spd * 0.5 - 0.125
        spd -= 0.5
        dtflag = False

print (ans)


N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
u = [0]
for vi, ti in zip(v, t):
  u[-1] = min(u[-1], vi)
  u += [vi] * (ti * 2)

u[-1] = 0
U = u.copy()
T = len(u)
for i in range(1, T):
  u[i] = min(u[i], u[i-1]+0.5)

for i in range(T-2, -1, -1):
  u[i] = min(u[i], u[i+1]+0.5)

ans = 0
for i in range(1, T):
  ans += (u[i-1] + u[i]) * 0.25

print(ans)

n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
v.append(0)

# forward
now = 0
for i in range(n):
    if now + t[i] < v[i]:
        v[i] = now + t[i]

    if v[i] <= v[i+1]:
        now = v[i]
    elif t[i] + v[i+1] + now < 2 * v[i]:
        v[i] = (t[i] + v[i+1] + now) / 2
        now = v[i+1]
    else:
        now = v[i+1]

# back
now = 0
for i in range(n-1, -1, -1):
    if now + t[i] < v[i]:
        v[i] = now + t[i]

    if v[i] <= v[i-1]:
        now = v[i]
    elif t[i] + v[i-1] + now < 2 * v[i]:
        v[i] = (t[i] + v[i-1] + now) / 2
        now = v[i-1]
    else:
        now = v[i-1]

ans = 0
now = 0
for i in range(n):
    t1 = v[i] - now
    t3 = v[i] - v[i+1]
    # t2 = t[i] - t1 - t3

    ans += now * t1 + t1 * t1 / 2
    now = v[i] # now += t1

    ans += now * (t[i] - t1 - t3) # ans += now * t2
    # now = now

    ans += now * t3 - t3 * t3 / 2
    now -= t3

print(ans)

n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
T = sum(t)

vmax_l = [0 for _ in range(2*T+1)]
vmax_r = [0 for _ in range(2*T+1)]
vmax = [0 for _ in range(2*T+1)]
for i in range(1, 2*T+1):
    tt = 0
    for j in range(n):
        if i > tt+t[j]*2:
            tt += t[j]*2
        else:
            vmax_l[i] = min(v[j], vmax_l[i-1]+0.5)
            break
for i in range(2*T-1, -1, -1):
    tt = 2*T
    for j in range(n-1, -1, -1):
        if i < tt-t[j]*2:
            tt -= t[j]*2
        else:
            vmax_r[i] = min(v[j], vmax_r[i+1]+0.5)
            break
for i in range(2*T+1):
    vmax[i] = min(vmax_l[i], vmax_r[i])

point_t = [0]
point_v = [0]
for i in range(1, 2*T):
    if vmax[i-1] != vmax[i] or vmax[i] != vmax[i+1]:
        point_t.append(i)
        point_v.append(vmax[i])
point_t.append(2*T)
point_v.append(0)

ans = 0
for i in range(1, len(point_t)):
    ans += (point_t[i]-point_t[i-1])*(point_v[i]+point_v[i-1])/4
print(ans)

N = int(input())
T = list(map(int, input().split()))
V1 = list(map(int, input().split()))
V1.append(0)

ST = [0] * (N + 1)
for i in range(N):
    ST[i + 1] = ST[i] + T[i]

V2 = [0] * N
for i in range(N):
    V2[i] = V1[i + 1] + ST[i + 1]
z = V2[-1]
for i in range(N - 1, -1, -1):
    if V2[i] > z:
        V2[i] = z
    else:
        z = V2[i]


Vmax = [0] * (ST[-1] * 2 + 1)
j = 0
t = 0
for i, Tn in enumerate(ST):
    while t < Tn or j == 0:
        Vmax[2 * t + j] = min(V1[i - 1], V2[i - 1])
        V2 = [x - 0.5 for x in V2]
        t += j
        j ^= 1

v, cnt = 0, 0
for i in range(ST[-1] * 2):
    nVmax = Vmax[i + 1]
    nv = min(v + 0.5, nVmax)
    cnt += (v + nv) * 0.5 / 2
    v = nv

print(cnt)


N = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))
T = sum(t)*2
vt = [min((i/2),((T-i)/2)) for i in range(T+1)]
ts = 0
te = 0
for i,ti in enumerate(t):
    te += ti*2
    vi = v[i]
    for j in range(ts,te):
        vt[j] = min(vt[j],vi)
    for j in range(te,T):
        if vt[j] >= (j-te)/2 + vi:
            vt[j] = (j-te)/2 + vi
        else:
            break
    for j in range(ts-1,-1,-1):
        if vt[j] >= -(j-ts)/2 + vi:
            vt[j] = -(j-ts)/2 + vi
        else:
            break
    ts = te
print(sum(vt)/2)

#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, T: "List[int]", V: "List[int]"):
    t_period = [0 for i in range(N+1)]
    for i in range(N):
        t_period[i+1] = t_period[i] + T[i]*2

    limit = np.zeros((t_period[N]+1,))
    for i in range(1, N):
        limit[t_period[i]] = min((V[i-1], V[i]))
    for i in range(N):
        limit[t_period[i]+1:t_period[i+1]] = V[i]
    
    speed = np.zeros((t_period[N]+1,))

    for v in range(1, 201):
        speed[1:t_period[N]] = np.min([limit[1:t_period[N]], speed[0:t_period[N]-1]+0.5, speed[2:t_period[N]+1]+0.5], axis=0)

    total = 0
    for t in range(t_period[N]):
        total += (speed[t] + speed[t+1]) * 0.5 * 0.5
    
    print(total)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    v = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, t, v)

def __starting_point():
    main()

__starting_point()

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

MAX_V = [0]
for t, v in zip(T, V):
    MAX_V[-1] = min(MAX_V[-1], v)
    MAX_V.extend([v] * (2 * t))

REAL_V = [0]
for i in range(len(MAX_V) - 1):
    REAL_V.append(min(REAL_V[-1] + 0.5, MAX_V[i + 1]))

REAL_V[-1] = 0
for i in reversed(list(range(len(MAX_V) - 1))):
    REAL_V[i] = min(REAL_V[i], REAL_V[i + 1] + 0.5, MAX_V[i])

ans = 0
for i in range(len(MAX_V) - 1):
    ans += ((REAL_V[i] + REAL_V[i + 1]) * 0.5) / 2
print(ans)


N = int(input())
t = [int(Ti) for Ti in input().split()]
v = [int(Vi) for Vi in input().split()]

v_max = [0]
for ti, vi in zip(t, v):
    v_max[-1] = min(v_max[-1], vi)
    for _ in range(2*ti):
        v_max.append(vi)

for i in range(len(v_max)-1):
    v_max[i+1] = min(v_max[i] + 0.5, v_max[i+1])

v_max[-1] = 0
for i in range(len(v_max)-2, -1, -1):
    v_max[i] = min(v_max[i], v_max[i+1] + 0.5)

area = 0
for i in range(len(v_max) - 1):
    area += 0.5 * 0.5 * (v_max[i] + v_max[i+1])

print(area)


#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, T: "List[int]", V: "List[int]"):
    t_period = [0 for i in range(N+1)]
    for i in range(N):
        t_period[i+1] = t_period[i] + T[i]*2

    V = [0] + V + [0]
    limit = np.zeros((N+2,t_period[N]+1))
    line = np.arange(0, t_period[N]/2+0.5, 0.5)
    for i in range(N+2):
        if i == 0:
            l, r = 0, 0
        elif i == N+1:
            l, r = t_period[N], t_period[N]
        else:
            l, r = t_period[i-1], t_period[i]
        limit[i] = np.max([-line + l * 0.5, line * 0, line - r * 0.5], axis=0) + V[i]
    speed = np.min(limit, axis=0)

    total = 0
    for t in range(t_period[N]):
        total += (speed[t] + speed[t+1]) * 0.5 * 0.5

    print(total)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    v = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, t, v)

def __starting_point():
    main()

__starting_point()

n = int(input())
t = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]
time = sum(t)

speed = [10 ** 9] * (2 * time + 1)
limit = [10 ** 9] * (2 * time + 1)

i = 0
for j, k in zip(t, v):
    for _ in range(j * 2):
        limit[i] = min(limit[i], k)
        i += 1
    limit[i] = min(limit[i], k)

s = 0
for i in range(2 * time + 1):
    s = min(s, limit[i])
    speed[i] = min(speed[i], s)
    s += 0.5
s = 0
for i in reversed(list(range(2 * time + 1))):
    s = min(s, limit[i])
    speed[i] = min(speed[i], s)
    s += 0.5

dist = 0
for i in range(2 * time):
    dist += (speed[i] + speed[i + 1]) / 4
print(dist)


import numpy as np

N = int(input())
t = np.array(['0'] + input().split(), np.int64)
v = list(map(int, input().split()))

# 発車してからn秒後の速度を求める

T = np.cumsum(t).tolist()
arrival = T[-1]
times = np.arange(0, arrival + 0.5, 0.5)
speed_limit = np.minimum(times, times[::-1])

for i, j, k in zip(T, T[1:], v):
    speed1 = i - times + k
    speed2 = np.full(arrival * 2 + 1, k, np.float)
    speed3 = times - j + k

    speed = np.maximum(speed1, speed3)
    speed = np.maximum(speed2, speed)
    speed_limit = np.minimum(speed_limit, speed)

answer = np.abs(speed_limit[1:] + speed_limit[:-1]) * 0.5 / 2
print((answer.sum()))


N=int(input())
T=list(map(int,input().split()))
V=list(map(int,input().split()))
need=[(0,0)]*(N+1)
now=0
for i in range(N-1):
    now+=T[i]
    need[i+1]=(now,min(V[i],V[i+1]))
need[N]=(now+T[N-1],0)
TN=need[N][0]
res=[float('inf')]*(TN+1)
for i in range(TN+1):
    for j in range(N+1):
        if j>0:
            if need[j-1][0]<=i<=need[j][0]:
                res[i]=min(res[i],V[j-1])
        res[i]=min(res[i],need[j][1]+abs(need[j][0]-i))
ans=0
for i in range(TN):
    if abs(res[i]-res[i+1])==1:
        ans+=0.5*(res[i]+res[i+1])
    else:
        for j in range(N):
            if need[j][0]<=i and i+1<=need[j+1][0]:
                vv=V[j]
                break
        if vv>res[i]:
            ans+=res[i]+0.25
        else:
            ans+=res[i]
print(ans)

N = int(input())
t = [0] + [int(x) for x in input().split()]
v = [0] + [int(x) for x in input().split()]

max_speed_from_left = [0] * (N+1) # index i = t[i],t[i+1]の間
max_speed_from_right = [0] * (N+1) # index i = t[i],t[i+1]の間

for i in range(1,N):
  start = max_speed_from_left[i-1]
  max_speed_from_left[i] = min(start + t[i], v[i], v[i+1])
  
for i in range(N-1,0,-1):
  start = max_speed_from_right[i+1]
  max_speed_from_right[i] = min(start + t[i+1], v[i], v[i+1])

speed = [min(x,y) for x,y in zip(max_speed_from_left,max_speed_from_right)]

def dist(left_speed,right_speed,t,v):
  x = (v - left_speed) + (v - right_speed)
  if x >= t:
    v = (left_speed + right_speed + t)/2
    x = t
  # 最高速度vに到達して、t-xあまる
  d = (left_speed + v) * (v-left_speed)/2
  d += v*(t-x)
  d += (right_speed + v) * (v-right_speed)/2
  return d

answer = 0
for i in range(1,N+1):
  answer += dist(speed[i-1],speed[i],t[i],v[i])
print(answer)


N=int(input().strip())
T=list(map(int,input().split()))
V=list(map(int,input().split()))
vtmax=[0]
tmp=0
Tsum=sum(T)
for t,v in zip(T,V):
    vtmax[-1]=min(tmp,v) #境界は小さい方が制約
    vtmax+=[v]*(t*2)
    tmp=v
vtmax[-1]=0

for i in range(1,2*Tsum):
    vtmax[i]=min(vtmax[i],vtmax[i-1]+0.5)
for i in range(2*Tsum-1,0,-1):
    vtmax[i]=min(vtmax[i],vtmax[i+1]+0.5)
area=0
for i,vt in enumerate(vtmax):
    if i==0:continue
    area+=0.5*(vt+vtmax[i-1])/2
print(area)

N=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))

T=sum(t)
ans=[0]

for i in range(N):
  ans[-1]=min(ans[-1],v[i])
  for j in range(t[i]*2):
    ans.append(v[i])

ans[-1]=0

for i in range(2*T):
  ans[i+1]=min(ans[i]+0.5,ans[i+1])

for i in range(2*T,0,-1):
  ans[i-1]=min(ans[i]+0.5,ans[i-1])

print(sum(ans)/2)

N = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))
T = sum(t)*2
vt = [(i/2) if i<T/2 else ((T-i)/2) for i in range(T+1)]
ts = 0
te = 0
for i,ti in enumerate(t):
    te += ti*2
    vi = v[i]
    for j in range(ts,te):
        vt[j] = min(vt[j],vi)
    for j in range(te,T):
        if vt[j] >= (j-te)/2 + vi:
            vt[j] = (j-te)/2 + vi
        else:
            break
    for j in range(ts-1,-1,-1):
        if vt[j] >= -(j-ts)/2 + vi:
            vt[j] = -(j-ts)/2 + vi
        else:
            break
    ts = te
print(sum(vt)/2)

import math
import numpy as np
import decimal
import collections
import itertools
import sys
import random
#Union-Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1 for i in range(self.n)]
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def unite(self, x, y):
        p = self.find(x)
        q = self.find(y)
        if p == q:
            return None
        if p > q:
            p, q = q, p
        self.par[p] += self.par[q]
        self.par[q] = p
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def size(self, x):
        return -self.par[self.find(x)]

#素数関連
def prime_numbers(x):
    if x < 2:
        return []
    prime_numbers = [i for i in range(x)]
    prime_numbers[1] = 0
    for prime_number in prime_numbers:
        if prime_number > math.sqrt(x):
            break
        if prime_number == 0:
            continue
        for composite_number in range(2 * prime_number, x, prime_number):
            prime_numbers[composite_number] = 0
    return [prime_number for prime_number in prime_numbers if prime_number != 0]
def is_prime(x):
    if x < 2:
        return False
    if x == 2 or x == 3 or x == 5:
        return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False
    prime_number = 7
    difference = 4
    while prime_number <= math.sqrt(x):
        if x % prime_number == 0:
            return False
        prime_number += difference
        difference = 6 - difference
    return True
#Prime-Factorize
def prime_factorize(n):
    res = []
    while n % 2 == 0:
        res.append(2)
        n //= 2
    f = 3
    while f ** 2 <= n:
        if n % f == 0:
            res.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        res.append(n)
    return res
#nCr
mod = 10 ** 9 + 7
class nCr():
    def __init__(self, n):
        self.n = n
        self.fa = [1] * (self.n + 1)
        self.fi = [1] * (self.n + 1)
        for i in range(1, self.n + 1):
            self.fa[i] = self.fa[i - 1] * i % mod
            self.fi[i] = pow(self.fa[i], mod - 2, mod)
    def comb(self, n, r):
        if n < r:return 0
        if n < 0 or r < 0:return 0
        return self.fa[n] * self.fi[r] % mod * self.fi[n - r] % mod
#拡張Euclidの互除法
def extgcd(a, b, d = 0):
    g = a
    if b == 0:
        x, y = 1, 0
    else:
        x, y, g = extgcd(b, a % b)
        x, y = y, x - a // b * y
    return x, y, g
#BIT
class BinaryIndexedTree():
    def __init__(self, n):
        self.n = n
        self.BIT = [0] * (self.n + 1)
    def add(self, i, x):
        while i <= self.n:
            self.BIT[i] += x
            i += i & -i
    def query(self, i):
        res = 0
        while i > 0:
            res += self.BIT[i]
            i -= i & -i
        return res
#Associative Array
class AssociativeArray():
    def __init__(self, q):
        self.dic = dict()
        self.q = q
    def solve(self):
        for i in range(self.q):
            Query = list(map(int, input().split()))
            if Query[0] == 0:
                x, y, z = Query
                self.dic[y] = z
            else:
                x, y = Query
                if y in self.dic:
                    print(self.dic[y])
                else:
                    print(0)
#Floor Sum
def floor_sum(n, m, a, b):
    res = 0
    if a >= m:
        res += (n - 1) * n * (a // m) // 2
        a %= m
    if b >= m:
        res += n * (b // m)
        b %= m
    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0:
        return res
    res += y_max * (n + (-x_max // a))
    res += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return res
#Z-Algorithm
def z_algorithm(s):
    str_len = len(s)
    res = [0] * str_len
    res[str_len - 1] = str_len
    i, j = 1, 0
    while i < str_len:
        while i + j < str_len and s[i + j] == s[j]:
            j += 1
        res[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < str_len and j > res[k] + k:
            res[i + k] = res[k]
            k += 1
        i += k
        j -= k
    return res
class Manacher():
    def __init__(self, s):
        self.s = s
    def coustruct(self):
        i, j = 0, 0 
        s_len = len(self.s)
        res = [0] * s_len
        while i < s_len:
            while i - j >= 0 and i + j < s_len and self.s[i - j] == self.s[i + j]:
                j += 1
            res[i] = j
            k = 1
            while i - k >= 0 and k + res[i - k] < j:
                k += 1
            i += k
            j -= k
#mod-sqrt
def mod_sqrt(a, p):
    if a == 0:
        return 0
    if p == 2:
        return 1
    k = (p - 1) // 2
    if pow(a, k, p) != 1:
        return -1
    while True:
        n = random.randint(2, p - 1)
        r = (n ** 2 - a) % p
        if r == 0:
            return n
        if pow(r, k, p) == p - 1:
            break
    k += 1
    w, x, y, z = n, 1, 1, 0
    while k:
        if k % 2:
            y, z = w * y + r * x * z, x * y + w * z
        w, x = w * w + r * x * x, 2 * w * x
        w %= p
        x %= p
        y %= p
        z %= p
        k >>= 1
    return y
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
s_t = sum(t)
ans = [0]
for i in range(n):
    ans[-1] = min(ans[-1], v[i])
    for j in range(t[i] * 2):
        ans.append(v[i])
ans.pop()
ans.append(0)
for i in range(1, s_t * 2 + 1):
    ans[i] = min(ans[i - 1] + 1 / 2, ans[i])
for i in range(1, s_t * 2 + 1)[::-1]:
    ans[i - 1] = min(ans[i] + 1 / 2, ans[i - 1])
print(sum(ans) / 2)

n = int(input())
ts = [int(item)*2 for item in input().split()]
vs = [int(item) for item in input().split()]

time = sum(ts) + 1
speed_l = [0] * time
speed_r = [0] * time 

t_id = 0
speed = 0
ts_copy = ts[:]
# Forward
for i in range(time+1):
    ts_copy[t_id] -= 1
    speed_l[i] = speed
    if speed >= vs[t_id]:
        speed = vs[t_id]
    else:
        speed += 0.5 

    if ts_copy[t_id] == 0:
        if t_id + 1 >= n:
            break
        t_id += 1

# Backward
speed = 0
for i in range(time-1, -1, -1):
    ts[t_id] -= 1
    speed_r[i] = min(speed, speed_l[i])
    if speed >= vs[t_id]:
        speed = vs[t_id]
    else:
        speed += 0.5 

    if ts[t_id] == 0:
        if t_id <= 0:
            break
        t_id -= 1

print(sum(speed_r) / 2.0)

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    tt=LI()
    vv=LI()+[0]
    #区間の変わり目においてのvの最大値を左右から調べる
    y=0
    max_vL=[1000]*(n-1)
    max_vR=[1000]*(n-1)
    for i in range(n-1):
        y=min(vv[i],vv[i+1],y+tt[i])
        max_vL[i]=y
    y=0
    for i in range(n-2,-1,-1):
        y=min(vv[i+1],vv[i],y+tt[i+1])
        max_vR[i]=y
    #print(max_vR)
    #print(max_vL)
    #左右のminを取ることで、変わり目のvを決める
    yy=[0]*(n+1)
    for i in range(n-1):
        yy[i+1]=min(max_vL[i],max_vR[i])
    #print(yy)
    #各区間の面積を求める
    ans=0
    for t,y0,y1,v in zip(tt,yy,yy[1:],vv):
        h=(t+y0+y1)/2
        ans+=((h+y0)*(h-y0)+(h+y1)*(h-y1))/2
        if h>v:ans-=(h-v)**2
    print(ans)

main()

n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
runtime = sum(t)
speed = [0] * (runtime*2+1)
now_t, now_v = 0,0
for ti,vi in zip(t,v):
  for i in range(now_t*2+1,now_t*2+ti*2+1):
    next_v = min(now_v+0.5, vi)
    speed[i] = next_v
    now_v = next_v
  now_t += ti
speed[-1] = 0
now_t, now_v = runtime,0
for ti,vi in zip(t[::-1],v[::-1]):
  for i in range(now_t*2-1,now_t*2-ti*2-1,-1):
    next_v = min([now_v+0.5, speed[i],vi])
    speed[i] = next_v
    now_v = next_v
  now_t -= ti
ans = 0
for i in range(runtime*2):
  ans += speed[i]+speed[i+1]
ans /= 4
print(ans)

import heapq
n=int(input())
inf=10000000000000
#始まりと終わりを保持
#同じオブジェクトにするやつで一時間溶かした、しね
ans=[[-1,-1] for i in range(n)]
ans[-1][1]=0
ans[0][0]=0
t=list(map(int,input().split()))
v=list(map(int,input().split()))
v2=[]
for i in range(n):
    heapq.heappush(v2,(v[i],i))
for i in range(n):
    #print(ans)
    y=heapq.heappop(v2)
    #print(y[1])
    #print(ans[y[1]])
    #print(y)
    #始まりをまずは決める
    if ans[y[1]][0]==-1:
        #print(2)
        now1=0
        ansi1=inf
        for j in range(y[1]-1,-1,-1):
            #print(ans1)
            if ans[j][1]!=-1:
                ansi1=min(ansi1,ans[j][1]+now1)
            now1+=t[j]
            if ans[j][0]!=-1:
                ansi1=min(ansi1,ans[j][0]+now1)
        now1=0
        for j in range(y[1],n):
            if ans[j][0]!=-1:
                ansi1=min(ansi1,ans[j][0]+now1)
            now1+=t[j]
            if ans[j][1]!=-1:
                ansi1=min(ansi1,ans[j][1]+now1)  
        ans[y[1]][0]=min(ansi1,y[0])
        ans[y[1]-1][1]=ans[y[1]][0]
        #print(ansi1)
    if ans[y[1]][1]==-1:
        #print(3)
        now2=0
        ansi2=inf
        for j in range(y[1],-1,-1):
            if ans[j][1]!=-1:
                ansi2=min(ansi2,ans[j][1]+now2)
            now2+=t[j]
            if ans[j][0]!=-1:
                ansi2=min(ansi2,ans[j][0]+now2)
        now2=0
        for j in range(y[1]+1,n):
            if ans[j][0]!=-1:
                ansi2=min(ansi2,ans[j][0]+now2)
            now2+=t[j]
            if ans[j][1]!=-1:
                ansi2=min(ansi2,ans[j][1]+now2)  
        ans[y[1]][1]=min(ansi2,y[0])
        ans[y[1]+1][0]=ans[y[1]][1]
        #print(ansi2)
answer=0
for i in range(n):
    h=min((t[i]+sum(ans[i]))/2,v[i])
    answer+=((h**2-ans[i][0]**2)/2)
    answer+=((h**2-ans[i][1]**2)/2)
    answer+=(h*(t[i]+sum(ans[i])-2*h))
print(answer)
#print(ans)



n = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))
T = sum(t)*2
kukan = [(0,0,0)]
for i in range(n):
    kukan.append((kukan[i][1],kukan[i][1]+t[i]*2,v[i]))
kukan.append((T,T,0))
vt = [[1000]*(len(kukan)) for _ in range(T+1)]
k = 0
for ts,te,v_ in kukan:
    for i in range(ts,te+1):
        vt[i][k] = v_
    for i in range(ts-1,-1,-1):
        vt[i][k] = vt[i+1][k]+0.5
    for i in range(te+1,T+1):
        vt[i][k] = vt[i-1][k]+0.5
    k += 1
ans = 0
d = [0]*len(vt)
for i in range(len(vt)):
    d[i] = min(vt[i])
for i in range(1,len(vt)):
    ans += (d[i]+d[i-1])*0.25
print(ans)

# AtCoder Beginner Contest 076
# D - AtCoder Express
# https://atcoder.jp/contests/abc076/tasks/abc076_d


def solve(T, V, velocity):
    accT = 1
    for t, max_v in zip(T, V):
        for i in range(accT, accT+2*t):
            velocity[i] = min(velocity[i], velocity[i-1]+0.5, max_v)
        accT += 2*t


def main():

    N, *A = list(map(int, open(0).read().split()))
    T = A[:N]
    V = A[N:]

    INF = 10**10

    velocity = [INF]*(sum(T)*2+1)
    velocity[0] = 0
    velocity[-1] = 0
    solve(T, V, velocity)
    velocity = velocity[::-1]
    solve(T[::-1], V[::-1], velocity)

    ans = 0
    pre_v = velocity[0]
    for v in velocity[1:]:
        ans += (pre_v + v) * 0.25
        pre_v = v

    print(ans)


def __starting_point():
    main()

__starting_point()

N = int(input())
T = [int(a) * 2 for a in input().split()]
V = [int(a) * 2 for a in input().split()]
MA = [0] * (sum(T) + 1)
a = 0
for i in range(N):
    for j in range(T[i]):
        a += 1
        MA[a] = min(MA[a-1] + 1, V[i])
MA[a] = 0
for i in range(N)[::-1]:
    for j in range(T[i]):
        a -= 1
        MA[a] = min(MA[a], MA[a+1] + 1, V[i])

print((sum(MA[1:]) + sum(MA[:-1])) / 8)

N = int(input())
T = [0] + list(map(int,input().split()))
V = [-1] + list(map(int,input().split()))

ans = 0
for i in range(1,N+1):
    T[i] += T[i-1]
time = T[-1]
upper  = {}

state = N
speed = 0

for t in range(2*time,0,-1):
    t *= 0.5
    if T[state-1] == t:
        speed = min(V[state],speed)
        state -= 1
    upper[t] = min(speed,V[state])
    speed += 0.5

speed = 0
pre = -1
Ans = []
for t in range(1,2*time+1):
    t = t*0.5
    speed += 0.5
    speed = min(speed,upper[t])
    Ans.append(speed)
    if pre == speed:
        ans += 0.5*speed
    elif pre > speed:
        ans += 0.5*speed + 0.125
    else:
        ans += 0.5*speed - 0.125
    pre = speed
print(ans)

n=int(input())
t=list(map(int,input().split()))
u=list(map(int,input().split()))
speed=[0]
for i in range(n):
  speed+=[u[i]]*t[i]*2
speed.append(0)
m=len(speed)
for i in range(1,m):
  speed[i-1]=min(speed[i-1],speed[i])
del speed[-1]
m-=1
for i in range(1,m):
  speed[i]=min(speed[i],speed[i-1]+0.5)
for i in range(m-2,-1,-1):
  speed[i]=min(speed[i],speed[i+1]+0.5)
ans=0
for i in range(1,m):
  ans+=abs(speed[i-1]+speed[i])*0.25
print(ans)

n = int(input())
list_t = list(map(int, input().split()))
list_v = list(map(int, input().split()))

list_v2 = [0 for i in range(n+1)]
list_t.append(0)
list_v.append(0)
for i in range(n-1)[::-1]:
  list_v2[i] = min(list_v[i], list_v[i+1], list_v2[i+1] + list_t[i+1])

dist = 0
v0 = 0
for i in range(n):
  t1 = min(list_v[i] - v0, (list_t[i] - (v0 - list_v2[i])) / 2, list_t[i])
  t2 = max(v0 + t1 - list_v2[i], 0)
  dist += (2*v0+t1)*t1/2 + (v0+t1)*(list_t[i]-t1-t2) + (2*(v0+t1)-t2)*t2/2
  v0 = v0 + t1 - t2
print(dist)

import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    t = f()
    v = f()
    


    sumt = sum(t)*2
    vs = [100000000] * (sumt+1)

    vs[0] = 0

    for i in range(1,sumt):
        totalt = 0
        idx = 0
        for k in range(n):
            totalt += t[k]*2
            if totalt >= i:
                idx = k
                break

        vs[i] = min(vs[i-1]+0.5, v[idx])

    vs[sumt] = 0
    for i in range(sumt-1, 0, -1):
        totalt = 0
        idx = 0
        for k in range(n):
            totalt += t[k]*2
            if totalt >= i+1:
                idx = k
                break

        vs[i] = min(vs[i+1]+0.5, vs[i], v[idx])

    ans = 0
    for i in range(sumt):
        ans += (vs[i]+ vs[i+1])/4


    # print(dict(zip(range(len(vs)), vs)))
    print(ans)

solve()


def main():
    N = int(input())
    T = list(map(int, input().split()))
    V = list(map(int, input().split()))
    T = [t * 2 for t in T]
    V = [v * 2 for v in V]
    Tall = sum(T)
    R = [0] * (Tall + 1)
    j = N - 1
    tc, vc, vn = T[-1], V[-1], V[-1]
    R[-1] = 0
    for i in reversed(list(range(Tall))):
        tc -= 1
        if tc == 0:
            j -= 1
            tc, vn = T[j], V[j]
        R[i] = min(R[i + 1] + 1, vc, vn)
        vc = vn
    v = 0
    d = 0.0
    j = 0
    tc, vc, vn = T[j], V[j], V[j]
    T.append(0)
    V.append(0)
    for i in range(1, Tall + 1):
        tc -= 1
        if tc == 0:
            j += 1
            tc, vn = T[j], V[j]
        vnn = min(v + 1, R[i], vc, vn)
        d += (v + vnn) / 2
        vc = vn
        v = vnn
    print((d / 4))

main()


n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))

cumsum_t = [0]*(n+1)
for i in range(n):
    cumsum_t[i+1] = cumsum_t[i] + t[i]

v_max = [0]*(2*sum(t) + 1)
for i in range(len(cumsum_t) - 1):
    for j in range(2*cumsum_t[i], 2*cumsum_t[i+1]):
        v_max[j] = v[i]
for i in range(len(cumsum_t) - 1):
    v_max[cumsum_t[i+1]*2] = min(v_max[cumsum_t[i+1]*2], v[i])

speed = [101]*(2*sum(t) + 1)
speed[0] = 0
speed[-1] = 0
for i in range(len(speed) - 1):
    speed[i+1] = min(speed[i+1], speed[i] + 0.5, v_max[i+1])
for i in range(len(speed) - 1)[::-1]:
    speed[i] = min(speed[i], speed[i+1] + 0.5, v_max[i])

print(sum(speed)/2)

n=int(input())
t=list(map(int,input().split()))
T=[-1,0]
for i in range(n):
  T.append(T[-1]+t[i])
T.append(T[-1]+1)
V=[0]+list(map(int,input().split()))+[0]
VV=[110]*(2*T[-1]+1)
for i in range(n+2):
  for j in range(2*T[-1]+1):
    if j<2*T[i]:
      a=T[i]-j/2
      VV[j]=min(VV[j],a+V[i])
    elif 2*T[i]<=j and j<=2*T[i+1]:
      VV[j]=min(VV[j],V[i])
    else:
      a=j/2-T[i+1]
      if a>100:
        break
      VV[j]=min(VV[j],a+V[i])
print(sum(VV)/2)

n=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))+[0]
for i in range(n-1,-1,-1):
    v[i]=min(v[i],v[i+1]+t[i])
ans=0
v0=0
for i in range(n):
    if v[i]<=v[i+1]:
        if v[i]-v0>t[i]:
            ans+=(2*v0+t[i])*t[i]/2
            v0=v0+t[i]
        else:
            ans+=t[i]*v[i]-(v[i]-v0)**2/2
            v0=v[i]
    else:
        if v[i]*2-v0-v[i+1]<t[i]:
            ans+=t[i]*v[i]-(v[i]-v0)**2/2-(v[i]-v[i+1])**2/2
            v0=v[i+1]
        elif v[i+1]-v0>t[i]:
            ans+=(2*v0+t[i])*t[i]/2
            v0=v0+t[i]
        else:
            d=abs(v0-v[i+1])
            ans+=max(v0,v[i+1])*t[i]-d**2/2+(t[i]-d)**2/4
            v0=v[i+1]
print(ans)

n = int(input())
t = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]

maxspeed = [0]*(n+1)
for i in range(n-1,0,-1):
    maxspeed[i] = min(v[i], v[i-1], t[i] + maxspeed[i+1])

def dist(i,first): # distance,lastspeed
    ta = v[i] - first
    tb = v[i] - maxspeed[i+1]
    if ta + tb <= t[i]:
        c = (first+v[i])*ta/2 + v[i]*(t[i]-ta-tb) + (maxspeed[i+1]+v[i])*tb/2
        lastspeed = maxspeed[i+1]
    elif maxspeed[i+1] - first > t[i]:
        c = (first + first + t[i])*t[i]/2
        lastspeed = first + t[i]
    else:
        a = (maxspeed[i+1]+t[i]-first)/2
        c = (first+first+a)*a/2 + (first+a+maxspeed[i+1])*(t[i]-a)/2
        lastspeed = maxspeed[i+1]
    return c, lastspeed


ans = 0
firstspeed = 0
for i in range(n):
    d,firstspeed = dist(i,firstspeed)
    ans += d

print(ans)    


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

Ttot = sum(T)
Wf = [0]*(Ttot+1)
Wb = [0]*(Ttot+1)

i = 0
w = 0
for t,v in zip(T,V):
    for j in range(t):
        i += 1
        w = min(w+1, v)
        Wf[i] = w

i = 0
w = 0
for t,v in zip(T[::-1],V[::-1]):
    for j in range(t):
        i += 1
        w = min(w+1, v)
        Wb[i] = w

ans = 0
wp = 0
wfp = 0
wbp = Wb[Ttot]
for i in range(1, Ttot+1):
    wf = Wf[i]
    wb = Wb[Ttot-i]
    
    w = min(wf, wb)
    ans += wp + 0.5*(w-wp)
    if wf-wfp==1 and wb-wbp==-1 and w==wp:
        ans += 0.25

    wp = w
    wfp = wf
    wbp = wb

print(ans)

# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
# 0.5考慮のため*2、終了時0のため番兵
A = [a*2 for a in LIST()] + [1]
B = [b*2 for b in LIST()] + [0]

def check1(i, t):
    nxtt = cur
    for j in range(i+1, N+1):
        nxtt += A[j-1]
        dist = nxtt - t
        # 1つ先で+1の状態でいても大丈夫かどうか
        if spd + 2 - dist > B[j]:
            return False
    return True

def check2(i, t):
    nxtt = cur
    for j in range(i+1, N+1):
        nxtt += A[j-1]
        dist = nxtt - t
        # 1つ先で今と同じ(+-0)の状態でいても大丈夫かどうか
        if spd + 1 - dist > B[j]:
            return False
    return True

cur = spd = sm = 0
for i, a in enumerate(A[:N]):
    b = B[i]
    # 各時点tにおいて加速、維持が可能かどうか確認
    for t in range(cur, cur+a):
        # 加速OK
        if spd + 1 <= b and check1(i, t):
            # この瞬間の加算分は増減の半分にする
            sm += spd + 0.5
            spd += 1
        # 維持OK
        elif spd <= b and check2(i, t):
            sm += spd
        # 減速必須
        else:
            sm += spd - 0.5
            spd -= 1
    cur += a
print((sm / 4))


#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, t: "List[int]", v: "List[int]"):
    bounds = [[] for _ in range(N)]
    gb0 = (1, 0)
    tend = sum(t)
    gb1 = (-1, tend)
    for i in range(N):
        bounds[i].append(gb0)
        bounds[i].append(gb1)
    stt = 0
    for i in range(N):
        ti = t[i]
        vi = v[i]
        end = stt + ti
        b0 = (-1, stt + vi)
        b1 = (0, vi)
        b2 = (1, -end + vi)
        for j in range(i):
            bounds[j].append(b0)
        bounds[i].append(b1)
        for j in range(i + 1, N):
            bounds[j].append(b2)
        stt = end
    stt = 0
    vms = [0] * (tend * 2 + 1)
    for i in range(N):
        end = stt + t[i]
        bi = bounds[i]
        inf = float("inf")
        mins = {-1: inf, 0: inf, 1: inf}
        for a, b in bi:
            mins[a] = min(mins[a], b)
        for tm in range(stt * 2, end * 2):
            vms[tm] = min(a * tm + b * 2 for a, b in list(mins.items()))
        stt = end
    print((sum(vms) / 4))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    v = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, t, v)


def __starting_point():
    main()

__starting_point()

N=int(input())
t=list(map(int, input().split()))
v=list(map(int, input().split()))
T=sum(t)
V=[0]*(T+2)
from collections import deque
q=[deque() for i in range(101)]
s=0
for i in range(N):
    temp=min(V[s],v[i])
    q[temp].append(s)
    for j in range(t[i]):
        V[s+j+1]=v[i]
    s+=t[i]
q[0].append(T)
vans=[-1]*(T+1)
for i in range(101):
    while(len(q[i])>0):
        s=q[i].popleft()
        if vans[s]==-1:
            vans[s]=i
        if s>0 and vans[s-1]==-1:
            if V[s]>i:
                q[i+1].append(s-1)
            else:
                q[i].append(s-1)
        if s<T and vans[s+1]==-1:
            if V[s+1]>i:
                q[i+1].append(s+1)
            else:
                q[i].append(s+1)
ans=0
for i in range(T):
    if vans[i+1]>vans[i]:
        ans+=vans[i]+0.5
    elif vans[i+1]<vans[i]:
        ans+=vans[i+1]+0.5
    elif V[i+1]>vans[i]:
        ans+=vans[i]+0.25
    else:
        ans+=vans[i]
print(ans)

n = int(input())
T = [0] + list(map(int, input().split()))
V = [0] + list(map(int, input().split())) + [0]

unit = 2

acumT = [0] * (n + 1)
for i in range(n):
  acumT[i+1] = acumT[i] + T[i+1]
  
PV = [0] * (sum(T) * unit + 1)
for p in range(1, n + 1):
  t1 = acumT[p-1]
  t2 = acumT[p]
# for (t1, t2), (v1, v2, v3) in zip(zip(acumT, acumT[1:]), zip(V, V[1:], V[2:])):
  for i in range(t1 * unit, t2 * unit + 1):
    ii = i / unit 
    PV[i] = min([ii - acumT[k] + V[k] for k in range(0, p)] + [V[p]] + [-ii + acumT[m] + V[m+1] for m in range(p, n+1)])

area = sum((i + j) / unit / 2 for i, j in zip(PV, PV[1:]))  
print(area)

n=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))
T=sum(t)
ansv=[0]
for i in range(n):
  ansv[-1]=min(ansv[-1],v[i])
  for j in range(t[i]*2):
    ansv.append(v[i])
ansv[-1]=0
#for i in range(len(ansv)):
#  print(i/2,ansv[i])
for i in range(2*T):
  ansv[i+1]=min(ansv[i]+0.5,ansv[i+1])
for i in range(2*T,0,-1):
  ansv[i-1]=min(ansv[i]+0.5,ansv[i-1])
print((sum(ansv)/2))
#print(len(ansv))
#for i in range(len(ansv)):
#  print(i/2,ansv[i])


import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
t = LI()
v = LI()

max_v = [0]*(N+1)  # 0秒後,t1秒後,t1+t2秒後,…の時点で出せる最大速度
for i in range(N-1):
    max_v[i+1] = min(v[i],v[i+1],max_v[i]+t[i])
for i in range(N-2,-1,-1):
    max_v[i+1] = min(max_v[i+1],v[i],v[i+1],max_v[i+2]+t[i+1])

ans = 0
for i in range(N):
    if t[i] >= (v[i]-max_v[i]) + (v[i]-max_v[i+1]):
        ans += t[i]*v[i]-(v[i]-max_v[i])**2/2-(v[i]-max_v[i+1])**2/2
    else:
        x = (t[i]+max_v[i]+max_v[i+1])/2
        ans += t[i]*x-(x-max_v[i])**2/2-(x-max_v[i+1])**2/2

print(ans)


import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

T = np.array(T).cumsum()
V = np.array(V)

va = []
i = 0
for t in np.arange(0, T[-1], 0.5):  # 0.5 区切りの時間
    if t < T[i]:
        va.append(V[i])
    else:
        i += 1
        va.append(min(V[i], V[i - 1]))
va.append(0)

v = 0
for i in range(len(va)):
    va[i] = min(va[i], v)
    v = va[i] + 0.5
v = 0
for i in reversed(list(range(len(va)))):
    va[i] = min(va[i], v)
    v = va[i] + 0.5

print(((np.array(va) / 2).sum()))


n=int(input())
inpt=list(map(int,input().split()))
inpv=list(map(int,input().split()))

t=inpt+[0]
v=inpv+[0]

T=sum(t)
M=[0]

nowt=2*t[0]
nowmaxv=v[0]
nowv=M[0]
i=0

for time in range(2*T):
    if nowv+0.5<=v[i]:
        M.append(nowv+0.5)
    else:
        M.append(nowv)
    nowt-=1
    nowv=M[-1]
    if nowt==0:
        i+=1
        nowt=2*t[i]
        nowmaxv=v[i]
        nowv=min(nowv,nowmaxv)
        
t=list(reversed(inpt))+[0]
v=list(reversed(inpv))+[0]
m=[0]

nowt=2*t[0]
nowmaxv=v[0]
nowv=M[0]
i=0

for time in range(2*T):
    if nowv+0.5<=v[i]:
        m.append(nowv+0.5)
    else:
        m.append(nowv)
    nowt-=1
    nowv=m[-1]
    if nowt==0:
        i+=1
        nowt=2*t[i]
        nowmaxv=v[i]
        nowv=min(nowv,nowmaxv)

ans=[min(M[i],m[-i-1]) for i in range(len(M))]
print(sum([min(ans[i],ans[i+1])+(ans[i+1]-ans[i])**2 for i in range(len(ans)-1)])/2)

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

N = int(input())
T = list(map(int,input().split()))
V = list(map(int,input().split()))

def calc_area(v1,v2,t,lim):
    if v1 > v2:
        v1,v2 = v2,v1
    if v2 == lim:
        if lim - v1 < t:
            return t*lim - (lim - v1)*(lim - v1)/2
        else:
            return (v1 + v2)*t/2
    else:
        if 2*lim - v1 - v2 < t:
            return t*lim - (lim - v1)*(lim - v1)/2 - (lim - v2)*(lim - v2)/2
        else:
            mid = (t + v2 - v1)/2
            return (mid + 2*v1)*mid/2 + (t - mid + 2*v2)*(t - mid)/2

def calc(N,T,V,maxv):
    ans = 0
    v = 0
    for i in range(N):
        next_v = min(v + T[i],maxv[i])
        ans += calc_area(v,next_v,T[i],V[i])
        v = next_v
    return ans

maxV = [0] * N
for i in range(N - 2,-1,-1):
    maxV[i] = min(maxV[i + 1] + T[i + 1],V[i],V[i + 1])
ans = calc(N,T,V,maxV) 
print(ans)

N=int(input())
inl=list([int(x)*2 for x in input().split()])
vs=list(map(int,input().split()))

sumtime = sum(inl)

limits = [0]
for i, t in enumerate(inl):
    for _ in range(t):
        limits.append(vs[i])

resv = [0]
for i in range(1, sumtime+1):
    resv.append(min(resv[-1]+0.5, limits[i]))

resv[sumtime] = 0
for i in reversed(list(range(1, sumtime+1))):
    resv[i-1] = min(resv[i]+0.5, resv[i-1], limits[i])

# print(limits)
# print(resv)
res = 0.0
for i in range(sumtime):
    res += (resv[i] + resv[i+1])*0.5

print((res*0.5))


#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def mileage(t, v, vl, vr):
    assert(0 <= vl <= v and 0 <= vr <= v)
    # 最高速度v, 左端での速度vl, 右端での速度vr, 秒数tの時の走行距離を求める
    l = v-vl
    r = t-(v-vr)
    if l > r:
        tmp = (l+r)/2
        l = tmp
        r = tmp
    ret = 0
    ret += l*l/2+vl*l
    ret += (r-l)*v
    ret += (t-r)*vr+(t-r)*(t-r)/2
    return ret

def main():
    n = ri()
    lt = rli()
    lv = rli()
    lt.append(0)
    lv.append(0)
    lefts = [0] # 各区間の左端での列車の速度
    for i in range(n):
        left = min(lefts[i]+lt[i], lv[i], lv[i+1])
        offset = 0
        for j in range(i+1, n+1):
            left = min(left, offset+lv[j])
            offset += lt[j]
        lefts.append(left)
    # print(lefts)
    ans = 0
    for i in range(n):
        ans += mileage(lt[i], lv[i], lefts[i], lefts[i+1])
    print(ans)


def __starting_point():
    main()

__starting_point()

N=int(input())
now=0
T=list(map(int,input().split()))
for i in range(1,N):
    T[i]+=T[i-1]
T=[-1*float('inf'),0]+T+[float('inf')]
V=list(map(int,input().split()))
V=[0]+V+[0]
vt=[float('inf')]*(T[-2]+1)
for t in range(len(vt)):
    now=t
    for k in range(N+2):
        if now<T[k]:
            vt[t]=min(vt[t],V[k]+T[k]-now)
        elif T[k]<=now<=T[k+1]:
            vt[t]=min(vt[t],V[k])
        elif T[k+1]<now:
            vt[t]=min(vt[t],V[k]+now-T[k+1])
ans=0
for i in range(len(vt)-1):
    if abs(vt[i+1]-vt[i])==1:
        ans+=0.5*(vt[i]+vt[i+1])
    elif vt[i+1]==vt[i]:
        for k in range(N+2):
            if T[k]<=i and i+1<=T[k+1]:
                vv=V[k]
                break
        if vv>vt[i]:
            ans+=0.5*(vt[i]*2+0.5)
        else:
            ans+=vt[i]
print(ans)

#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, T: "List[int]", V: "List[int]"):
    t_period = [0 for i in range(N+1)]
    for i in range(N):
        t_period[i+1] = t_period[i] + T[i]*2

    limit = np.zeros((t_period[N]+1,))
    for i in range(1, N):
        limit[t_period[i]] = min((V[i-1], V[i]))
    for i in range(N):
        limit[t_period[i]+1:t_period[i+1]] = V[i]
    
    speed = np.zeros((t_period[N]+1,))

    for v in range(1, 201):
        speed[v:t_period[N]+1-v] = np.min(
            [limit[v:t_period[N]+1-v], speed[v-1:t_period[N]-v]+0.5, speed[v+1:t_period[N]+2-v]+0.5],
            axis=0
            )

    total = 0
    for t in range(t_period[N]):
        total += (speed[t] + speed[t+1]) * 0.5 * 0.5
    
    print(total)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    v = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, t, v)

def __starting_point():
    main()

__starting_point()

def main():
    n = int(input())
    t = list(map(int, input().split()))
    v = list(map(int, input().split()))
    back_lim = []
    lim = []
    for i in range(n):
        for _ in range(t[i]):
            back_lim.append(v[i])
            lim.append(v[i])
    back_lim.append(0)
    for i in reversed(list(range(len(back_lim)-1))):
        back_lim[i] = min(back_lim[i], back_lim[i+1]+1)
    ans = 0.0
    p = 0
    for i in range(len(back_lim)-1):
        if p < back_lim[i+1]:
            if p < lim[i]:
                ans += p + 0.5
                p += 1
            else:
                ans += p
        elif p == back_lim[i+1]:
            if p < lim[i]:
                ans += p + 0.25
            else:
                ans += p
        else:
            ans += p - 0.5
            p -= 1
    print(ans)

def __starting_point():
    main()

__starting_point()


import sys, collections, bisect, math, itertools
from fractions import gcd 
input = sys.stdin.readline #文字列入力のときは注意

n = int(input())
t = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]

maxspeed = [0]*(n+1)
for i in range(n-1,0,-1):
    maxspeed[i] = min(v[i], v[i-1], t[i] + maxspeed[i+1])

#print(t)
#print(v)
#print(maxspeed)

def dist(first,i): # distance,lastspeed
    ti = t[i]
    vi = v[i]
    mi1= maxspeed[i+1]
    ta = vi - first
    tb = vi - mi1
    if ta + tb <= ti:
        c = (first+vi)*ta/2 + vi*(ti-ta-tb) + (mi1+vi)*tb/2
        lastspeed = mi1
    elif mi1 - first > ti:
        c = (first + first + ti)*ti/2
        lastspeed = first + ti
    else:
        a = (mi1+ti-first)/2
        c = (first+first+a)*a/2 + (first+a+mi1)*(ti-a)/2
#        print(a,'a',c,first,(first+first+a)*a/2, (first+a+mi1)*(ti-a)/2)
        lastspeed = mi1
#    print(c)

    return c, lastspeed


ans = 0
firstspeed = 0
for i in range(n):
    d,firstspeed = dist(firstspeed,i)
#    print(d,firstspeed)
    ans += d

print(ans)    
    









N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))

# if N == 1: #最初の1区間だけ
#     if t[0] % 2 == 1: #奇数秒
#         if t[0]/2 < v[0]:
#             print ((t[0]/2) ** 2)
#             return
        

# print ('t', t)
# print ('v', v)
N_INF = - 10 ** 15
DP = [[N_INF] * (102) for _ in range(100 * 200 + 2)] #DP[T][V] := 時刻Tに速度Dで走っているときの時刻Tまでの走行距離の最大値
DP[0][0] = 0
# print (DP[0][0:5])
time = 1
for i in range(N):
    # print (i)
    # print ('time', time)
    for j in range(time, time + t[i]): #時刻
        # print (j, end = ' ')
        for k in range(0, v[i] + 1): #速度
            if k == 0: #速度0-->加速して速度0になることはない
                # print (j, k)
                # print (max(DP[j - 1][0], DP[j - 1][1] +  1/2))
                DP[j][k] = max(DP[j - 1][0] + 0.25, DP[j - 1][1] + 1/2)
            elif k != v[i]: #加速してくるときも減速してくることもある
                DP[j][k] = max(DP[j - 1][k -1] + k - 1/2, DP[j - 1][k] + k + 0.25, DP[j - 1][k + 1] + k + 1/2)
            else: #(k == v[i] and j != time) #減速してくることはない
                DP[j][k] = max(DP[j - 1][k -1] + k - 1/2, DP[j - 1][k] + k)
        # print (DP[j][0:5])
    time += t[i]
# print (time)
print((DP[time - 1][0]))
# print ('T = 6, V = 6', DP[6][6])
# print ('T = 12, V = 2', DP[12][2])
# print ('T = 12, V = 3', DP[12][3])
# print ('T = 13, V = 2', DP[13][2])
# print ('T = 26 V = 2', DP[26][2])
# print ('T = 27 V = 2', DP[27][2])


from itertools import accumulate

N = int(input())
T = [int(s) for s in input().split()]
V = [int(s) for s in input().split()] + [0]
lt = sum(T)
S = list(accumulate(T))

for i in range(len(T), 0, -1):
    V[i-1] = min(V[i-1], V[i] + T[i-1])

vel2 = [0] * (2 * lt + 1)
for i in range(len(T)):
    ti = T[i]
    tr = S[i]
    for ts in range(tr - ti, tr):
        for t in (2 * ts + 1, 2 * ts + 2):
            if vel2[t-1] - (2 * tr - (t - 1)) == 2 * V[i+1]:
                vel2[t] = vel2[t-1] - 1
            elif vel2[t-1] == 2 * V[i]:
                vel2[t] = vel2[t-1]
            else:
                vel2[t] = vel2[t-1] + 1
ans = sum([(vel2[t-1] + vel2[t]) / 8 for t in range(1, 2 * lt + 1)])
print(ans)


n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))

maxv = [0]
for _t, _v in zip(t, v):
  maxv[-1] = min(maxv[-1], _v)
  for ti in range(_t * 2):
    maxv.append(_v)

N = len(maxv)
candv = [0] * N
for i in range(N - 1):
  candv[i + 1] = min(candv[i] + 0.5, maxv[i + 1])

candv[-1] = 0
for i in reversed(list(range(1, N))):
  candv[i - 1] = min(candv[i - 1], candv[i] + 0.5)

ans = 0
for x1, x2 in zip(candv, candv[1:]):
  ans += (x1 + x2) * 0.5 / 2

print(ans)


import heapq
n=int(input())
inf=10000000000000
ans=[[-1,-1] for i in range(n)]
ans[-1][1],ans[0][0]=0,0
t=list(map(int,input().split()))
v=list(map(int,input().split()))
v2=[]
for i in range(n):
    heapq.heappush(v2,(v[i],i))

def next(y,wh):
    nonlocal ans,n
    ansi=inf
    if wh:
        r1,r2=range(y[1]-1,-1,-1),range(y[1],n)
    else:
        r1,r2=range(y[1],-1,-1),range(y[1]+1,n)
    now=0
    for j in r1:
        if ans[j][1]!=-1:
            ansi=min(ansi,ans[j][1]+now)
        now+=t[j]
        if ans[j][0]!=-1:
            ansi=min(ansi,ans[j][0]+now)
    now=0
    for j in r2:
        if ans[j][0]!=-1:
            ansi=min(ansi,ans[j][0]+now)
        now+=t[j]
        if ans[j][1]!=-1:
            ansi=min(ansi,ans[j][1]+now)  
    if wh:
        ans[y[1]][0]=min(ansi,y[0])
        ans[y[1]-1][1]=ans[y[1]][0]
    else:
        ans[y[1]][1]=min(ansi,y[0])
        ans[y[1]+1][0]=ans[y[1]][1]  

for i in range(n):
    y=heapq.heappop(v2)
    if ans[y[1]][0]==-1:next(y,True)
    if ans[y[1]][1]==-1:next(y,False)
answer=0
for i in range(n):
    h=min((t[i]+sum(ans[i]))/2,v[i])
    answer+=((h**2-ans[i][0]**2)/2)
    answer+=((h**2-ans[i][1]**2)/2)
    answer+=(h*(t[i]+sum(ans[i])-2*h))
print(answer)

import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


# 配列から累積和を返す
def make_cumulative(A):
    C = [0] * (len(A) + 1)
    for i, a in enumerate(A):
        i += 1
        C[i] = C[i - 1] + a
    return C


def main():
    N = NI()
    T = [0] + NLI()
    V = [0] + NLI() + [0]
    B = [[] for _ in range(N+1)]
    cum_T = make_cumulative(T)[1:]

    limits = [[] for _ in range(N)]
    for i, v in enumerate(V):
        for t in range(N):
            if t == i-1:
                limits[t].append([v, 0])
            elif t == i:
                limits[t].append([v, 1])
            elif t < i-1:
                limits[t].append([v + (cum_T[i-1] - cum_T[t]), -1])
            else:
                limits[t].append([v + (cum_T[t] - cum_T[i]), 1])
    limits = [sorted(l) for l in limits]


    ans = 0
    for li, limit in enumerate(limits):
        if limit[0][1] == -1:
            ans += limit[0][0] * T[li+1] - T[li+1]**2 / 2
            continue

        if limit[0][1] == 0:
            next_l = limit[1]
            for j in range(1, len(limit)):
                if limit[j][1] == -1:
                    next_l = limit[j]
                    break
            if next_l[1] == -1 and next_l[0] < limit[0][0] + T[li+1]:
                ans += limit[0][0] * T[li+1] - (limit[0][0]-next_l[0]+T[li+1])**2 / 2
            else:
                ans += limit[0][0] * T[li+1]
            continue

        stay = [l for l in limit if l[1] == 0]
        down = [l for l in limit if l[1] == -1]
        if down == []:
            down_l = [10**5, -1]
        else:
            down_l = down[0]
        if stay == []:
            stay_l = [10**5, 0]
        else:
            stay_l = stay[0]

        if down_l[0] >= limit[0][0] + T[li+1]*2:
            ans += limit[0][0] * T[li + 1] + T[li + 1] ** 2 / 2
            if limit[0][0] < stay_l[0] < limit[0][0] + T[li+1]:
                ans -= (limit[0][0] + T[li+1] - stay_l[0])**2 / 2
        else:
            h = (down_l[0] - limit[0][0])/2
            if stay_l[0] >= limit[0][0] + h:
                ans += (limit[0][0]+h) * T[li+1] - h**2/2 - (T[li+1]-h)**2/2
                continue

            m, M = min(limit[0][0], down_l[0]-T[li+1]), max(limit[0][0], down_l[0]-T[li+1])
            if M < stay_l[0] < limit[0][0] + h:
                ans += (limit[0][0] + h) * T[li + 1] - h ** 2/2 - (T[li + 1] - h) ** 2/2
                ans -= (limit[0][0] + h - stay_l[0]) ** 2
                continue

            if stay_l[0] <= M:
                ans += stay_l[0] * T[li+1] - (stay_l[0]-limit[0][0])**2 / 2
                continue

    print(ans)


def __starting_point():
    main()
__starting_point()

import numpy as np
 
N=int(input())
T=list(map(int,input().split()))
V=list(map(int,input().split()))

MAX_V=[0]
for t,v in zip(T,V):
  MAX_V[-1]=min(MAX_V[-1],v)
  for _ in range(t*2):
    MAX_V.append(v)
  #print(MAX_V)
  #print(len(MAX_V))

timelistsize=len(MAX_V)
REAL_V=[0]*timelistsize

#スピードが加速する部分の速度を表現
for i in range(1,timelistsize):
  REAL_V[i]=min(REAL_V[i-1]+0.5,MAX_V[i])

#終了位置から同じようにして減速部分の速度を表現
REAL_V[-1]=0
for i in range(timelistsize-1,0,-1):
  REAL_V[i-1]=min(REAL_V[i]+0.5,REAL_V[i-1])


#0.5秒刻みの速度ができているので、0.5を高さ,0.5秒ごとの速度を上辺,下辺とした台形面積を足す
answer=0
for i in range(timelistsize-1):
  answer+=((REAL_V[i]+REAL_V[i+1])*0.5/2)
print(answer)

'''
tsum=np.sum(t)
print(tsum)
 
Ruisekit=[t[0]]
 
for i in range(1,N):
  Ruisekit.append(t[i]+Ruisekit[i-1])
  
print(Ruisekit)
 
 
 
 
downstart=[]
 
for i in range(N-1):
  if v[i]>v[i+1]:
    downstart.append(t[i]-(v[i]-v[i+1]))
 
print(downstart)
 
velocity=0
downindex=0
 
if downstart:
  nextdownstarttime=downstart[downindex]
 
state='up'
upstarttime=0
upstartspeed=0
answer=0
maxspeed=v[0]
maxspeedindex=0
 
for time in range(1,tsum+1):
  if state=='up':
    velocity+=1
    #print('velocity:',velocity)
    #print('time',time)
  if state=='down':
    velocity-=1
  if time==nextdownstarttime:
    if state=='plane':
      answer+=(time-planestarttime)*speed
    state='down'
    print(state)
    downstarttime=time
    downstartspeed=speed
    downindex+=1
    if downindex<len(downstart):
      nextdownstarttime=downstart[downindex]
  if time==Ruisekit[maxspeedindex]:
    maxspeedindex+=1
    if maxspeedindex<len(v):
      maxspeed=v[maxspeedindex]
  if velocity==maxspeed and state!='plane':
    if state=='up':
      answer+=(time-upstarttime)*(velocity-upstartspeed)*0.5
      answer+=(time-upstarttime)*upstartspeed
    if state=='down':
      answer+=(time-downstarttime)*(downstartspeed-velocity)*0.5
      answer+=(time-downstarttime)*downstartspeed
    
    state='plane'
    planestarttime=time
    speed=velocity
    
  print(answer,time,maxspeed,velocity,state)
''' 

n = int(input())
t = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]

m = [0]*(n+1)
z = [0]*(n+1)
for i in range(n-1,0,-1):
    m[i] = min(v[i], v[i-1], t[i] + m[i+1])
for i in range(1,n):
    z[i] = min(m[i], z[i-1]+t[i-1])

def dist(i):
    lspeed = z[i]
    rspeed = z[i+1]
    ta = v[i] - lspeed
    tb = v[i] - rspeed
    if ta + tb <= t[i]: # 山を押さえた形
        c = (lspeed+v[i])*ta/2 + v[i]*(t[i]-ta-tb) + (rspeed+v[i])*tb/2
    else: #山の形
        a = (rspeed+t[i]-lspeed)/2
        c = (2*lspeed+a)*a/2 + (lspeed+a+rspeed)*(t[i]-a)/2
    return c

ans=0
for i in range(0,n):
    ans += dist(i)

print(ans)    



def main():
    buf = input()
    N = int(buf)
    buf = input()
    buflist = buf.split()
    t = list(map(int, buflist))
    buf = input()
    buflist = buf.split()
    v = list(map(int, buflist))
    t.append(0)
    v.append(0)
    for i, _ in enumerate(t): # double time and speed to make calculation easier
        t[i] *= 2
        v[i] *= 2
    time = 0
    last_speed = 0
    speed = 0
    distance = 0.0
    point = 0
    spd_time_list = []
    for i, _ in enumerate(t):
        spd_time_list.append((v[i], (0 if not spd_time_list else t[i-1] + spd_time_list[-1][1])))
    while time < spd_time_list[-1][1]:
        last_speed = speed
        brake = False
        for i in range(point+1, len(spd_time_list)):
            if speed >= spd_time_list[i][0] + (spd_time_list[i][1] - time):
                brake = True
                break
        if brake:
            speed -= 1
        elif speed < spd_time_list[point][0]:
            speed += 1
        distance += (last_speed + speed) / 2
        time += 1
        if time >= spd_time_list[point+1][1]:
            point += 1
    distance /= 4 # roll back time and speed (and so the distance)
    print(distance)

def __starting_point():
    main()

__starting_point()

n=int(input())
t=[int(i) for i in input().split()]
v=[int(i) for i in input().split()]
l=[]

for i in range(n):
    l+=[v[i]]*t[i]*2

l=[min(i,j) for i,j in zip([0]+l,l+[0])]

for i in range(1,len(l)):
    l[i]=min(l[i],l[i-1]+0.5)
for i in range(len(l)-1)[::-1]:
    l[i]=min(l[i],l[i+1]+0.5)

ans=0

for i in range(1,len(l)):
    ans+=0.25*(l[i]+l[i-1])

print(ans)

n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
tmp = 0
e_t = []
for i in t:
    tmp+=i
    e_t.append(tmp)

def calc_end_speed(s):
    end_time = e_t[s]
    ma = 10**10
    for i in range(s+1, n):
        ma = min(e_t[i-1] - end_time + v[i], ma)
    return min(e_t[-1] - end_time, v[s], ma)

ans = 0
start_speed = 0

for sect in range(n):
    end_speed = min(calc_end_speed(sect), start_speed+t[sect])
    turn_time = (t[sect]+end_speed-start_speed)/2
    acce_end = min(v[sect]-start_speed, turn_time)
    dece_start = max(t[sect]-(v[sect]-end_speed) ,turn_time)
    max_speed = start_speed+acce_end
    ans += (start_speed+max_speed)*acce_end/2
    ans += max_speed*(dece_start-acce_end)
    ans += (end_speed+max_speed)*(t[sect]-dece_start)/2
    start_speed = end_speed

print(ans)

f=lambda line,x:line[0]*x+line[1]
def _add_line(line,k,l,r):
    m=(l+r)//2
    if not data[k]:
        data[k]=line
        return
    lx,mx,rx=X[l],X[m],X[r-1]
    left,mid,right=f(line,lx)<f(data[k],lx),f(line,mx)<f(data[k],mx),f(line,rx)<f(data[k],rx)
    if left and right:
        data[k]=line
        return
    if not left and not right:return
    if mid:data[k],line=line,data[k]
    if left!=mid:_add_line(line,2*k+1,l,m)
    else:_add_line(line,2*k+2,m,r)
def add_line(line,a,b):
    L,R=a+N0,b+N0
    a0,b0=a,b
    sz=1
    while L<R:
        if R&1:
            R-=1
            b0-=sz
            _add_line(line,R-1,b0,b0+sz)
        if L&1:
            _add_line(line,L-1,a0,a0+sz)
            L+=1
            a0+=sz
        L>>=1
        R>>=1
        sz<<=1
def query(k):
    x=X[k]
    k+=N0-1
    s=10**18
    while k>=0:
        if data[k]:
            t=f(data[k],x)
            if t<s:s=t
        k=(k-1)//2
    return s
n,*t=map(int,open(0).read().split())
t,v=t[:n],t[n:]
st=sum(t)*2
m=a=i=0
N0=2**(st).bit_length()
data=[None]*(2*N0+1)
X=list(range(st+1))+[10**18]*N0
i=b=0
add_line((.5,0),0,st+1)
for u,w in zip(t,v):
    u+=u+i
    add_line((0,w),i,u)
    add_line((-.5,w+i/2),0,i+1)
    add_line((.5,w-u/2),u,st+1)
    i,b=u,w
add_line((-.5,st/2),0,st+1)
a=x=0
for i in range(1,st+1):
    y=query(i)
    a+=(x+y)/4
    x=y
print(a)

N = int(input())
T = list(map(int,input().split()))
V = list(map(int,input().split()))
max_t = sum(T)
vl = [0]*(max_t+1)
vr = [0]*(max_t+1)
vm = [0]*(max_t+1)
t = 0
for s, u in zip(T,V):
  for i in range(t,t+s):
    vm[t] = u
    t += 1
t = 1
for s, u in zip(T,V):
  for i in range(t, t+s):
    vl[t] = min(u, vl[t-1]+1)
    t += 1
t = max_t
for s, u in zip(T[::-1],V[::-1]):
  for i in range(t-s,t)[::-1]:
    vr[t-1] = min(u,vr[t]+1)
    t -= 1
v = [min(vl[i],vr[i]) for i in range(max_t+1)]
#print(vm)
#print(vl)
#print(vr)
#print(v)
ans = 0
for i in range(max_t):
  ans += (v[i] + v[i+1]) / 2
  if v[i] == v[i+1] and v[i] != vm[i]:
    ans += 0.25
print("{:.10f}".format(ans))

# Atcoder Express
from bisect import bisect_left, bisect_right
N = int(input())
time = list(map(int, input().split()))
vel = list(map(int, input().split()))
sum_t = [0 for i in range(N+1)]

for i in range(1, N+1):
    sum_t[i] = sum_t[i-1]+time[i-1]

dp = [[-float("inf") for j in range(101)] for i in range(20001)]
# dp[t][v]=開始からt秒後に速度v で走っている時に、t秒後に実現できる最大の移動距離
dp[0][0] = 0

for i in range(1, sum_t[-1]+1):
    # i秒後における更新

    bef = bisect_left(sum_t, i-1)
    phase = bisect_left(sum_t, i)

    bef_bound = vel[bef-1]  # i-1秒時点における速度制限
    bound = vel[phase-1]    # i秒後における速度制限
    if bef == 0:
        bef_bound = 100
        
    if bef_bound < bound:
        for j in range(bef_bound+2):
            if j == 0:
                if j+1 <= bef_bound:
                    dp[i][j] = max(dp[i-1][j]+j+0.25, dp[i-1][j+1]+j+0.5)
                else:
                    if j == bef_bound:
                        dp[i][j] = dp[i-1][j]+j+0.25

            elif j >= 1:
                if j+1 <= bef_bound:
                    dp[i][j] = max(dp[i-1][j-1]+j-0.5, dp[i-1]
                                   [j]+j+0.25, dp[i-1][j+1]+j+0.5)
                else:
                    if j == bef_bound:
                        dp[i][j] = max(dp[i-1][j-1]+j-0.5, dp[i-1][j]+j+0.25)
                    else:
                        if j-1 == bef_bound:
                            dp[i][j] = dp[i-1][j-1]+j-0.5

    elif bef_bound >= bound:
        for j in range(bound):
            if j == 0:
                # j+1<=bef_bound:
                dp[i][j] = max(dp[i-1][j]+j+0.25, dp[i-1][j+1]+j+0.5)
            elif j >= 1:
                dp[i][j] = max(dp[i-1][j-1]+j-0.5, dp[i-1]
                               [j]+j+0.25, dp[i-1][j+1]+j+0.5)

        dp[i][bound] = max(dp[i-1][bound]+bound, dp[i-1][bound-1]+bound-0.5)


ans = dp[sum_t[-1]][0]
print(ans)


import numpy as np

N = int(input())
t = np.array(['0'] + input().split(), np.int64)
v = list(map(int, input().split()))

# 発車してからn秒後の速度を求める

T = np.cumsum(t).reshape(-1, 1)
arrival = T[-1]
times = np.arange(0, arrival + 0.5, 0.5)
speed_limit = np.minimum(times, times[::-1])

V = np.array(v).reshape(-1, 1)
answer = np.minimum(times, times[::-1])
tmp = np.maximum(T[:-1, :] - times, times - T[1:, :]) + V
tmp = np.maximum(tmp, V)
tmp = tmp.min(axis=0)
answer = np.minimum(tmp, answer)
answer = np.abs(answer[1:] + answer[:-1]) * 0.5 / 2

print((answer.sum()))


N = int(input())
T = [2 * int(i) for i in input().split()]
V = [2 * int(i) for i in input().split()]

su = sum(T)
A = [min(i, su - i) for i in range(su + 1)]

cnt = 0
for t, v in zip(T, V):
    for i in range(cnt, cnt + t + 1):
        A[i] = min(A[i], v)
    cnt += t

for i in range(su):
    A[i + 1] = min(A[i + 1], A[i] + 1)

for i in reversed(range(su)):
    A[i] = min(A[i], A[i + 1] + 1)

print(sum(A) / 4)

N = int(input())
*T, = map(int, input().split())
*V, = map(int, input().split())
speed = [0] # speed[i]: speed of train after 0.5*i seconds
for t, v in zip(T, V):
    speed[-1] = min(speed[-1], v)
    speed += [v]*(2*t)
speed[-1] = 0
temp = 0
for t in range(1, len(speed)):
    speed[t] = temp =  min(speed[t], temp + 0.5)
temp = 0
for t in range(len(speed)-1, 0, -1):
    speed[t] = temp =  min(speed[t], temp + 0.5)
ans = sum((v1 + v2)/4 for v1, v2 in zip(speed, speed[1:]))
print(ans)

N = int(input())
tlist = list(map(int, input().split()))
vlist = list(map(int, input().split()))
vlist.append(0)
flag = True
while flag:
    flag =  False
    for i in range(N):
        if vlist[i]-vlist[i+1] > tlist[i]:
            vlist[i] = vlist[i+1]+tlist[i]
            flag = True
speed = 0
x = 0
for i in range(N):
    ti = tlist[i]
    vi = vlist[i]
    vj = vlist[i+1]
    if vi <= vj:
        if vi-speed <= ti:
            x += ti*vi - ((vi-speed)**2)/2
            speed = vi
        else:
            x += ti*(speed+ti) - (ti**2)/2
            speed += ti
    else:
        if speed+ti <= vj:
            x += ti*(speed+ti) - (ti**2)/2
            speed += ti
        elif 2*vi-speed-vj <= ti:
            x += ti*vi - ((vi-speed)**2)/2 - ((vi-vj)**2)/2
            speed = vj
        else:
            a = (ti+vj-speed)/2
            x += a*(2*speed+a)/2 + (ti-a)*(2*vj+ti-a)/2
            speed = vj
print(x)

N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
def exe(x, y, z, t):
  ans = t * y
  if x < y:
    ans -= (y - x) * (y - x) / 2
  if y > z:
    ans -= (y - z) * (y - z) / 2
  return ans

def upd(x, y, z, t):
  a = y - x
  b = y - z
  if y > z:
    if t < a:
      y = x + t
    elif t < a + b:
      y = x + (t + (z - x)) / 2
  else:
    if t < a:
      y = x + t
  return y

v = [0] + v + [0]
L = [0] * len(v)
v[1] = upd(v[0], v[1], v[2], t[0])
v[-2] = upd(v[-1], v[-2], v[-3], t[-1])
for i in range(1, N):
  k = -1
  for j in range(1, N + 1):
    if L[j] == 0:
      if k == -1:
        k = j
      else:
        if v[j] < v[k]:
          k = j
  L[k] = 1
  if k != 1:
    v[k - 1] = upd(min(v[k], v[k - 2]), v[k - 1], max(v[k], v[k - 2]), t[k - 2])
  if k != N:
    v[k + 1] = upd(min(v[k], v[k + 2]), v[k + 1], max(v[k], v[k + 2]), t[k])

ans = 0
for i in range(N):
  ans += exe(v[i], v[i + 1], v[i + 2], t[i])

print(ans)

N = int(input())
T = [int(a) * 2 for a in input().split()]
V = [int(a) * 2 for a in input().split()]
MA = [0] * (sum(T) + 1)
a = 0
for i in range(N):
    for j in range(T[i]):
        a += 1
        MA[a] = min(MA[a-1] + 1, V[i])
MA[a] = 0
for i in range(N)[::-1]:
    for j in range(T[i]):
        a -= 1
        MA[a] = min(MA[a], MA[a+1] + 1, V[i])

print(((sum(MA[1:]) + sum(MA[:-1])) / 8))


N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))


V = [100] * (2*sum(t) + 1)
T = 0
for i in range(N):
    for j in range(T+1, T+t[i]*2+1):
        V[j] = min(V[j], v[i])
    T += t[i]*2

for i in range(min(len(V), 201)):
    V[i] = min(V[i], i*0.5)
for i in range(min(len(V), 201)):
    V[-i-1] = min(V[-i-1], i*0.5)
V
T = 0
for i in range(N-1):
    T += t[i]*2
    vi = min(V[T], v[i], v[i+1])
    for j in range(201):
        if T-j >= 0:
            V[T-j] = min(V[T-j], vi+0.5*j)
        if T+j <= len(V)-1:
            V[T+j] = min(V[T+j], vi+0.5*j)

V
ans = 0
for i in range(len(V)-1):
    ans += 0.5*0.5*(V[i]+V[i+1])
print(ans)


N = int(input())
t = [0] + list(map(int, input().split()))
v = [0] + list(map(int, input().split()))
max_speed_from_left = [0] * (N + 1) #index i = t[i] とt[i + 1]の間
max_speed_from_right = [0] * (N + 1) #index i = t[i] とt[i + 1]の間

for i in range(1, N):
    start = max_speed_from_left[i - 1]
    max_speed_from_left[i] = min(start + t[i], v[i], v[i + 1])

for i in range(N - 1, 0, -1):
    start = max_speed_from_right[i + 1]
    max_speed_from_right[i] = min(start + t[i + 1], v[i], v[i + 1])

speed = [min(x, y) for x, y in zip(max_speed_from_left, max_speed_from_right)]

def dist(left_speed, right_speed, t, v):
    x = (v - left_speed) + (v - right_speed)
    if x >= t:
        v = (left_speed + right_speed + t)/2
        x = t
    #最高速度vに到達してt-x余る
    d = (left_speed + v) * (v - left_speed)/2
    d += v * (t - x)
    d += (right_speed + v) * (v - right_speed)/2
    return d

ans = 0
for i in range(1, N + 1):
    ans += dist(speed[i -1], speed[i], t[i], v[i])
print (ans)

     



from collections import deque

def main():
    with open(0) as f:
        N, *Temp = map(int, f.read().split())
        T, V = Temp[:N], Temp[N:]
        del Temp
    #v-tグラフを仮定して、各区間の境界条件を求める
    v_left = deque([0]) #初期時刻から走査した結果
    v_right = deque([0]) #終了時刻から走査した結果
    #区間i(1<=i<=N)の境界条件は [min(vin[i-1], vout[i-1]), max(vin[i], vout[i])
    #走査処理
    now = 0
    for t,v in zip(T, V):
        now = min(now+t, v)
        v_left.append(now)
    now = 0
    for t, v in zip(reversed(T), reversed(V)):
        now = min(now+t, v)
        v_right.appendleft(now)

    BC = [min(x,y) for x,y in zip(v_left, v_right)] #境界条件
    #区間ごとに2倍の面積計算
    S = [squareMeasure(vin, vout, vsup, t) for vin, vout, vsup, t in zip(BC[:N], BC[1:], V, T)]
    ans = sum(S)/2
    print(ans)

def squareMeasure(vin, vout, vsup, t):
    vmax = (t+vout+vin)/2 #y=x+vinとy=-x+t+vout の交点のy
    if vmax > vsup:
        a, b = vsup-vin, t+vout-vsup #y=vsupと2直線の交点
        S = (vin+vsup)*a + 2*(b-a)*vsup + (vsup+vout)*(t-b)
    else:
        S = (vin+vmax)*(vmax-vin) + (vmax+vout)*(t+vin-vmax)
    return S #2倍の面積である

def __starting_point():
    main()
__starting_point()

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

vel_go = [0]
for ti, v_lim in zip(T, V):
    for _ in range(ti * 2):
        v = min(vel_go[-1] + 0.5, v_lim)
        vel_go.append(v)

vel_back = [0]
for ti, v_lim in zip(T[::-1], V[::-1]):
    for _ in range(ti * 2):
        v = min(vel_back[-1] + 0.5, v_lim)
        vel_back.append(v)
vel_back.reverse()

velocity = tuple(min(x, y) for x, y in zip(vel_go, vel_back))
ans = sum(0.25*(x+y) for x, y in zip(velocity[:-1], velocity[1:]))
print(ans)

N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))

maxv = [0] + [min(v[i], v[i+1]) for i in range(N-1)] + [0]
for i in reversed(range(N)):
  if maxv[i] - maxv[i+1] > t[i]:
    maxv[i] = maxv[i+1] + t[i]
for i in range(N):
  if maxv[i+1] - maxv[i] > t[i]:
    maxv[i+1] = maxv[i] + t[i]

def kyori(start, stop, mxv, ti):
  if stop >= start:
    if stop - start >= ti:
      return (stop+start)*ti /2
    elif mxv <= stop:
      return ti*mxv - (mxv-start)**2 /2
    else:
      x = (stop-start+ti)/2
      if mxv >= start + x:
        return (start+start+x)*x /2 + (stop+stop+ti-x)*(ti-x) /2
      else:
        return ti*mxv - ((mxv-start)**2 + (mxv-stop)**2)/2
  else:
    x = (stop-start+ti)/2
    if mxv >= start + x:
      return (start+start+x)*x /2 + (stop+stop+ti-x)*(ti-x) /2
    else:
      return ti*mxv - ((mxv-start)**2 + (mxv-stop)**2)/2


ans = 0
for i in range(N):
  ans += kyori(maxv[i], maxv[i+1], v[i], t[i])

print(ans)

n=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))
x=[0]
for i in range(n):x+=[v[i]]*t[i]*2
x+=[0]
l=[min(x[i],x[i+1])for i in range(len(x)-1)]
for i in range(1,len(l)):l[i]=min(l[i],l[i-1]+0.5)
for i in range(len(l)-2,-1,-1):l[i]=min(l[i],l[i+1]+0.5)
print(sum(0.25*(l[i]+l[i-1])for i in range(1,len(l))))

N=int(input())
T=list(map(int,input().split()))
V=list(map(int,input().split()))

vel_go=[0]
for ti, v_lim in zip(T,V):
    for _ in range(ti*2):
        v = min(vel_go[-1] + 0.5, v_lim)
        vel_go.append(v)

vel_back = [0]
for ti, v_lim in zip(T[::-1], V[::-1]):
    for _ in range(ti*2):
        v = min(vel_back[-1] + 0.5, v_lim)
        vel_back.append(v)
vel_back.reverse()

velocity = tuple(min(x,y) for x, y in zip(vel_go, vel_back))
ans = sum(0.25*(x+y) for x,y in zip(velocity[:-1], velocity[1:]))
print(ans)

# solution

import io
import math
import scipy.sparse
import numpy

data = int(input())

array1 = list(map(lambda x:int(x)*2,input().split()))

array2 = list(map(lambda x:int(x)*2,input().split()))

sumt = sum(array1)

maxv = [min(i, sumt-i) for i in range(sumt+1)]

counter = 0

for t,v in zip(array1,array2):
    for i in range(counter,counter+t+1):
        maxv[i] = min(maxv[i], v)
    counter += t

for i in range(sumt):
    maxv[i+1] = min(maxv[i+1], maxv[i] + 1)
for i in reversed(range(sumt)):
    maxv[i] = min(maxv[i], maxv[i+1] + 1)

print(sum(maxv) / 4)

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
M = 2
dt = 1 / M
R = sum(T)

maxSpeeds = [10**18] * (R * M + 1)
now = 0
for t, v in zip(T, V):
    for i in range(t * M + 1):
        maxSpeeds[now + i] = min(maxSpeeds[now + i], v)
    now += t * M

maxSpeeds[0] = 0
maxSpeeds[-1] = 0
for t in range(1, R * M + 1):
    maxSpeeds[t] = min(maxSpeeds[t - 1] + dt, maxSpeeds[t])
    maxSpeeds[-(t + 1)] = min(maxSpeeds[-t] + dt, maxSpeeds[-(t + 1)])

ans = 0
for l, r in zip(maxSpeeds, maxSpeeds[1:]):
    ans += (l + r) / M / 2
print(ans)

n = int(input())

time = [0]+list(map(int,input().split()))+[0]
v = [0] + list(map(int,input().split()))+[0]

lines = []
t = 0
lines.append((-1,0,0))
for i in range(1,n+1):
    lines.append((t,t+time[i],v[i]))
    t+=time[i]
lines.append((t,t+1,0))
def f(x):
    speed = 10**18
    for x1,x2,vv in lines:
        if x<x1:
            speed = min(speed,vv+x1-x)
        elif x>x2:
            speed = min(speed,vv+x-x2)
        else:
            speed = min(speed,vv)
    return speed
dp = [0]*(2*t)
for i in range(2*t):
    dp[i] = f(i/2)
dp.append(0)
res = 0
res = sum(dp)*2-dp[0]-dp[-1]
print((res*0.25))


import sys
from heapq import heapify, heappop
from bisect import bisect_left, bisect_right, insort_left
read=sys.stdin.read
readline=sys.stdin.readline

def main():
    n=int(readline())
    t,v=(list(map(int,l.split())) for l in read().splitlines())
    vi=[(x,i+1) for i,x in enumerate(v)]
    x=[0]*(n+2)
    y=[0]*(n+1)
    x[0]=0
    y[0]=0
    y[-1]=0
    for i in range(1,n+1):
        x[i]=x[i-1]+t[i-1]
    x[n+1]=x[n]
    heapify(vi)
    ans=0
    v=[0]+v+[0]
    memo=[0,n+1]
    while vi:
        e=heappop(vi)
        insort_left(memo,e[1])
        idx=bisect_left(memo,e[1])
        _i=memo[idx-1]
        i_=memo[idx+1]
        i=memo[idx]
        sx=x[_i]
        gx=x[i_-1]
        sy=y[_i]
        gy=y[i_-1]
        h=e[0]
        y[i]=min(h,gx-x[i]+gy,x[i]-sx+sy)
        y[i-1]=min(h,gx-x[i-1]+gy,x[i-1]-sx+sy)
        dw=gx-sx
        dh=abs(gy-sy)
        be=max(0,dw-(2*max(v[_i],v[i_])-sy-gy))
        ht=min(h-v[_i],h-v[i_],be/2)
        te=max(0,be-2*ht)
        ans+=(te+be)*ht/2
    print(ans)

def __starting_point():
    main()

__starting_point()

n = int(input())
t = [0]+list(map(int,input().split()))
v = [0]+list(map(int,input().split()))

left = [0]*(n+1)
right = [0]*(n+1)

for i in range(1,n):
    s = left[i-1]
    left[i] = min(s+t[i],v[i],v[i+1])
for i in range(n-1,0,-1):
    s = right[i+1]
    right[i] = min(s+t[i+1],v[i],v[i+1])

ad = [min(x,y) for x,y in zip(left,right)]

def cal(le,ri,t,v):
    x = v-le+v-ri
    if x >= t:
        v = (le+ri+t)/2
        x = t
    d = (le+v)*(v-le)/2
    d += v*(t-x)
    d += (ri+v)*(v-ri)/2
    return d

ans = 0
for i in range(1,n+1):
    ans += cal(ad[i-1],ad[i],t[i],v[i])
print(ans)

# 写経AC
N = int(input())
T = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]

Ts = sum(T)

# Vmax[t]: t秒での最大速度 (0.5秒間隔)
Vmax = [float("inf")] * (Ts * 2 + 1)

ts = 0
for i in range(N):
    for t in range(T[i]):
        t1 = (ts + t) * 2
        t2 = (ts + t) * 2 + 1
        Vmax[t1] = min(Vmax[t1], V[i])
        Vmax[t2] = min(Vmax[t2], V[i])

    # 時間の区切りの部分は閉区間が重なっている
    Vmax[(ts + T[i]) * 2] = min(Vmax[(ts + T[i]) * 2], V[i])

    ts += T[i]

# 0秒とT秒
Vmax[0] = Vmax[Ts * 2] = 0
# 左から右に
for t in range(Ts * 2):
    Vmax[t + 1] = min(Vmax[t + 1], Vmax[t] + 0.5)
# 右から左に
for t in range(Ts * 2 - 1, 0, -1):
    Vmax[t] = min(Vmax[t], Vmax[t + 1] + 0.5)

ans = 0.0
for i in range(Ts * 2):
    # 台形の公式
    ans += (Vmax[i] + Vmax[i + 1]) * 0.5 / 2

print(ans)

N = int(input())
T = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]

maxv = [0]
for t, v in zip(T, V):
    maxv[-1] = min(maxv[-1], v)
    for i in range(t * 2):
        maxv.append(v)
maxv[-1] = 0

for i in range(len(maxv) - 1):
    maxv[i + 1] = min(maxv[i + 1], maxv[i] + 0.5) 
    
for i in reversed(range(len(maxv) - 1)):
    maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)
    
ans = 0
for i in range(len(maxv) - 1):
    ans += (maxv[i] + maxv[i + 1]) * 0.5 / 2
    
print(ans)