AtCoder Beginner Contest 076 - AtCoder Express

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.

Source: atcoder | Difficulty: MEDIUM


Solutions:
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)
dtflag = False
for i in range(alltime * 2 + 1):
	if spd < maxslis[i]:
		ans += spd * 0.5 + 0.125
		spd += 0.5
	elif spd == maxslis[i]:
		ans += spd * 0.5
		dtflag = False
	else:
		ans += spd * 0.5 - 0.125
		spd -= 0.5
		dtflag = False
print(ans)


n = int(input())
t = [int(x) for x in input().split()]
v = [int(x) for x in input().split()]
tTotal = sum(t) * 2
speed = [min(i / 2, (tTotal - i) / 2) for i in range(tTotal + 1)]
start = 0
end = 0
for i in range(n):
	end += t[i] * 2
	for j in range(tTotal + 1):
		speed[j] = min(speed[j], v[i] + max(0, -(j - start) / 2, (j - end) / 2))
	start = end
print(sum(speed) / 2)


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7
INF = float('inf')

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

def dist(i, j, lim, t):
	if abs(i - j) > t:
		dist = -INF
	else:
		x = (t + j - i) / 2
		y = (t + j + i) / 2
		if y <= lim:
			dist = (i + y) * x / 2 + (j + y) * (t - x) / 2
		else:
			dist = (i + lim) * (lim - i) / 2 + lim * (t - (lim - i) - (lim - j)) + (j + lim) * (lim - j) / 2
	return dist

def main():
	N = int(input())
	T = getlist()
	V = getlist()
	DP = [[-INF] * 101 for i in range(N + 1)]
	DP[0][0] = 0
	for i in range(N - 1):
		lim = V[i]
		t = T[i]
		for p in range(lim + 1):
			for q in range(lim + 1):
				d = dist(p, q, lim, t)
				DP[i + 1][q] = max(DP[i + 1][q], DP[i][p] + d)
	lim = V[-1]
	t = T[-1]
	for p in range(lim + 1):
		d = dist(p, 0, lim, t)
		DP[N][0] = max(DP[N][0], DP[N - 1][p] + d)
	print(DP[N][0])
main()


def main():
	n = int(input())
	(*t,) = map(int, input().split())
	tot = sum(t)
	(*v,) = map(int, input().split())
	lim1 = []
	lim2 = [(1, 0, 0), (-1, tot, tot)]
	til = 0
	for (t1, t2, v1) in zip([0] + t, t, v):
		lim1.append((til, til + t2, v1))
		lim2.append((-1, til, til + v1))
		lim2.append((1, til + t2, v1 - (til + t2)))
		til += t2

	def mi(time):
		ret = float('inf')
		for (l, r, lim) in lim1:
			if l <= time <= r:
				ret = min(ret, lim)
		for (f, tt, y) in lim2:
			if f == -1 and time <= tt:
				ret = min(ret, y - time)
			if f == 1 and time >= tt:
				ret = min(ret, time + y)
		return ret
	print(sum((mi(i / 2) for i in range(tot * 2 + 1))) / 2)
main()


N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
t = [0] + t
for i in range(N):
	t[i + 1] += t[i]
y = [0] * (t[N] * 2 + 1)
for (i, (t1, t2)) in enumerate(zip(t, t[1:])):
	for x in range(2 * t1, 2 * t2):
		y[x + 1] = min(v[i], y[x] + 0.5)
y[2 * t[N]] = 0
for (i, (t1, t2)) in enumerate(zip(t[::-1], t[::-1][1:])):
	for x in range(2 * t1, 2 * t2, -1):
		y[x - 1] = min(y[x - 1], v[N - i - 1], y[x] + 0.5)
print(sum(((y[i] + y[i + 1]) * 0.5 for i in range(t[N] * 2))) / 2)


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])
res = 0.0
for i in range(sumtime):
	res += (resv[i] + resv[i + 1]) * 0.5
print(res * 0.5)


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
MAX_V = [0]
for (v, t) in zip(V, T):
	MAX_V[-1] = min(MAX_V[-1], v)
	for ti in range(t * 2):
		MAX_V.append(v)
for i in range(1, len(MAX_V)):
	MAX_V[i] = min(MAX_V[i - 1] + 0.5, MAX_V[i])
MAX_V[-1] = 0
for i in range(len(MAX_V) - 2, -1, -1):
	MAX_V[i] = min(MAX_V[i], MAX_V[i + 1] + 0.5)
ans = 0
for i in range(len(MAX_V) - 1):
	ans += (MAX_V[i] + MAX_V[i + 1]) * 0.5 / 2
print(ans)


n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
v.append(0)
t.append(1)
sumoftimes = [0]
currentsum = 0
for i in range(n + 1):
	currentsum += t[i]
	sumoftimes.append(currentsum)
ans = []
for i in range(2 * sumoftimes[n] + 1):
	a = 10 ** 9
	for j in range(n + 1):
		if 2 * sumoftimes[j] <= i:
			if j > 0:
				a = min(a, i / 2 - sumoftimes[j] + v[j - 1])
		else:
			a = min(a, sumoftimes[j] - i / 2 + v[j])
	a = min(a, i / 2)
	for j in range(n):
		if i < 2 * sumoftimes[j + 1]:
			a = min(a, v[j])
			break
	if i == 2 * sumoftimes[n]:
		a = 0
	ans.append(a)
finalans = 0
for i in range(len(ans) - 1):
	finalans += (ans[i] + ans[i + 1]) / 4
print(finalans)


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
operations = T[:]
v_limits = V[:]
v = 0
limits_x = [0]
for i in range(N):
	for _ in range(operations[i] * 2):
		v += 0.5
		limit = min(v, v_limits[i])
		limits_x.append(limit)
		v = limit
v = 0
limits_y = [0]
for i in reversed(range(N)):
	for _ in range(operations[i] * 2):
		v += 0.5
		limit = min(v, v_limits[i])
		limits_y.append(limit)
		v = limit
limits_y = list(reversed(limits_y))
limits_z = [min(x, y) for (x, y) in zip(limits_x, limits_y)]
ans = 0
for (_z, z) in zip(limits_z[:-1], limits_z[1:]):
	ans += (_z + z) * 0.5 / 2
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(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 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])

def dist(first, i):
	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
		lastspeed = mi1
	return (c, lastspeed)
ans = 0
firstspeed = 0
for i in range(n):
	(d, firstspeed) = dist(firstspeed, i)
	ans += d
print(ans)


N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
bound = [0 for _ in range(N + 1)]
for i in range(N - 1):
	bound[i + 1] = min(v[i], v[i + 1], bound[i] + t[i])
for i in range(N - 1, 0, -1):
	bound[i] = min(bound[i], bound[i + 1] + t[i], v[i], v[i - 1])
sum = 0
for i in range(N):
	if (bound[i] + bound[i + 1] + t[i]) / 2 > v[i]:
		sum += (bound[i] + v[i]) * (v[i] - bound[i]) / 2
		sum += (bound[i + 1] + v[i]) * (v[i] - bound[i + 1]) / 2
		sum += v[i] * (t[i] - 2 * v[i] + bound[i] + bound[i + 1])
	else:
		sum += (bound[i + 1] - bound[i] + t[i]) * 0.5 * (bound[i + 1] + 3 * bound[i] + t[i]) * 0.5 * 0.5
		sum += (t[i] + bound[i] - bound[i + 1]) * 0.5 * (bound[i] + 3 * bound[i + 1] + t[i]) * 0.5 * 0.5
print(sum)


import numpy as np
N = int(input())
t = np.array(['0'] + input().split(), np.int64)
v = list(map(int, input().split()))
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())


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)


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()))
MAX_T = 200
MAX_V = 100
INF = 1000000000.0
index = 0
tsum = 0
T = sum(t)
dp = [[-INF] * (2 * MAX_V + 1) for i in range(2 * T + 1)]
dp[0][0] = 0.0
for i in range(2 * T):
	if i + 1 > 2 * (tsum + t[index]):
		tsum += t[index]
		index += 1
	for j in range(2 * MAX_V + 1):
		jj = 0.5 * j
		if jj > v[index]:
			continue
		if jj < v[index]:
			dp[i + 1][j + 1] = max((dp[i + 1][j + 1], dp[i][j] + 0.5 * jj + 0.125))
		if jj > 0:
			dp[i + 1][j - 1] = max((dp[i + 1][j - 1], dp[i][j] + 0.5 * jj - 0.125))
		dp[i + 1][j] = max((dp[i + 1][j], dp[i][j] + 0.5 * jj))
print(dp[2 * T][0])


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

def solve(N, T, V):
	from itertools import accumulate
	ds = [0] + list(accumulate(T))
	vs = [0] + [min(V[i], V[i + 1]) for i in range(len(V) - 1)] + [0]
	for i in range(len(vs)):
		d = ds[i]
		vs[i] = min([v + abs(d - ds[j]) for (j, v) in enumerate(vs)])

	def calc(t, v0, v1, maxv):
		t0 = maxv - v0
		t1 = maxv - v1
		if t0 + t1 < t:
			return t * maxv - t0 * t0 / 2 - t1 * t1 / 2
		else:
			t0 = (t + v1 - v0) / 2
			t1 = (t + v0 - v1) / 2
			v = (t + v0 + v1) / 2
			S = v * t - t0 * t0 / 2 - t1 * t1 / 2
			return S
	r = 0
	for i in range(N):
		c = calc(T[i], vs[i], vs[i + 1], V[i])
		r += c
	return r
print(solve(N, T, V))


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)


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):
		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
	print(distance)

def __starting_point():
	main()
__starting_point()


def main():
	N = int(input())
	T = list(map(int, input().split()))
	V = list(map(int, input().split())) + [0]
	CT = [0 for x in range(N + 1)]
	M = [float('inf') for x in range(len(T))]
	count = 0
	ct = 0
	for (t, v) in zip(T, V[:N]):
		CT[count] = ct
		ct += t
		count += 1
	CT[N] = ct
	for n in range(N):
		for i in range(n + 1):
			M[i] = min(M[i], V[n + 1] + (CT[n + 1] - CT[i]))
	now = 0
	S = 0
	for q in range(len(T)):
		future = M[q]
		restriction = V[q]
		for s in range(T[q] * 2):
			future -= 0.5
			pnow = now
			now = min(min(future, restriction), now + 0.5)
			S += (now + pnow) / 4
	print(S)
main()


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)


N = int(input())
T = [int(x) for x in input().split()]
V = [int(x) for x in input().split()]
import itertools
tv = [0] + list(itertools.chain(*[[v] * t * 2 for (t, v) in zip(T, V)])) + [0]
for i in itertools.accumulate(T):
	tv[i * 2] = min(tv[i * 2], tv[i * 2 + 1])
for i in range(len(tv) - 1, 0, -1):
	if tv[i] < tv[i - 1] - 0.5:
		tv[i - 1] = tv[i] + 0.5
	elif tv[i] > tv[i - 1] + 0.5:
		for j in range(i, len(tv) - 1):
			if tv[j - 1] + 0.5 < tv[j]:
				tv[j] = tv[j - 1] + 0.5
			else:
				break
print(sum([(v1 + v2) * 0.5 * 0.5 for (v1, v2) in zip(tv[1:], tv[:-1])]))


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)


import sys

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))
mod = 10 ** 9 + 7
inf = float('inf')
N = I()
t = LI()
v = LI()
T = sum(t) * 2
vcandi = [[0] * (N + 2) for _ in range(T + 1)]
sumt = int(0)
for i in range(N):
	time = t[i] * 2
	for j in range(sumt):
		vcandi[j][i] = v[i] + (sumt - j) * 0.5
	for j in range(time + 1):
		vcandi[sumt + j][i] = v[i]
	sumt = sumt + time
	for j in range(T - sumt + 1):
		vcandi[sumt + j][i] = v[i] + j * 0.5
for i in range(T + 1):
	vcandi[i][N] = i * 0.5
	vcandi[i][N + 1] = (T - i) * 0.5
ansV = [0] * (T + 1)
for i in range(T + 1):
	ansV[i] = min(vcandi[i])
cur = float(0)
for i in range(T):
	cur += (ansV[i] + ansV[i + 1]) / 2 * 0.5
ans = cur
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 = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]
T_p = [0, 0]
temp = 0
for tt in T:
	temp += tt
	T_p.append(temp)
T_p.append(temp)
Tmax = temp

def vv(i, tt):
	a = T_p[i]
	b = T_p[i + 1]
	if i == 0 or i == N + 1:
		vmax = 0
	else:
		vmax = V[i - 1]
	if tt >= b:
		res = tt - b + vmax
	elif tt <= a:
		res = a - tt + vmax
	else:
		res = vmax
	return res
mints = [min([vv(i, tt / 2) for i in range(N + 2)]) for tt in range(2 * Tmax + 1)]
res = 0
for i in range(len(mints) - 1):
	res += (mints[i] + mints[i + 1]) / 4
print(res)


N = int(input())
t = [0] + list(map(int, input().split())) + [0]
v = [0] + list(map(int, input().split())) + [0]
for i in range(N, 0, -1):
	v[i] = min(v[i], v[i + 1] + t[i])
for i in range(1, N + 1):
	v[i] = min(v[i], v[i - 1] + t[i])
ans = 0
v_f = 0
for i in range(1, N + 1):
	v_l = min(v_f + t[i], v[i + 1], v[i])
	if 2 * v[i] - v_f - v_l <= t[i]:
		ans += (v[i] + v_f) * (v[i] - v_f) / 2 + v[i] * (t[i] - 2 * v[i] + v_f + v_l) + (v[i] + v_l) * (v[i] - v_l) / 2
	else:
		t_1 = (t[i] + v_l - v_f) / 2
		t_2 = t[i] - t_1
		ans += (2 * v_f + t_1) * t_1 / 2 + (2 * v_l + t_2) * t_2 / 2
	v_f = v_l
print('{:.10f}'.format(ans))


from itertools import accumulate
N = int(input())
t = [0] * 2 + list(map(int, input().split())) + [0]
v = [0] + list(map(int, input().split())) + [0]
N += 3
at = list(accumulate(t))
T = at[-1]
s = [0] * (2 * T + 1)
minvs = []
for i in range(2 * T + 1):
	t = i * 0.5
	minv = 10 ** 10
	for j in range(N - 1):
		if t < at[j]:
			tmpv = v[j] + (at[j] - t)
		elif at[j] <= t and t <= at[j + 1]:
			tmpv = v[j]
		else:
			tmpv = v[j] + (t - at[j + 1])
		minv = min(minv, tmpv)
	minvs.append(minv)
ans = 0.0
for i in range(2 * T):
	ans += (minvs[i] + minvs[i + 1]) * 0.25
print(ans)


n = int(input())
trng = [0] + list(map(int, input().split())) + [0]
vlim = [0] + list(map(int, input().split())) + [0]
n += 2
smt = sum(trng)
table = [[-1 for i in range(smt * 2 + 1)] for j in range(n)]
acc = 0
for i in range(n):
	if i == 0:
		for j in range(smt * 2 + 1):
			table[i][j] = j / 2
	elif i == n - 1:
		for j in range(smt * 2 + 1):
			table[i][j] = smt - table[0][j]
	else:
		v = vlim[i]
		t = trng[i]
		for j in range(acc):
			table[i][j] = v + (acc - j) / 2
		for j in range(acc, acc + t * 2 + 1):
			table[i][j] = v
		acc += t * 2
		for j in range(acc + 1, smt * 2 + 1):
			table[i][j] = v + (j - acc) / 2
ans = 0
ansls = list(zip(*table))
for arr in ansls:
	ans += min(arr) * 0.5
print(ans)


import sys
sys.setrecursionlimit(10000000)

def input():
	return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *
N = int(input())
(t, v) = (list(map(int, input().split())), list(map(int, input().split())))
s = sum(t) * 2
u = [[0.5 * i, 0.5 * (s - i)] for i in range(s + 1)]
T = [0] * (N + 1)
for i in range(N):
	T[i + 1] = T[i] + t[i]
for i in range(s):
	now = 0.5 * i
	for j in range(N):
		if now < T[j]:
			u[i].append(v[j] + T[j] - now)
		elif T[j] <= now <= T[j + 1]:
			u[i].append(v[j])
		else:
			u[i].append(v[j] + now - T[j + 1])
for i in range(s + 1):
	u[i] = min(u[i])
ans = 0
for i in range(s):
	ans += (u[i] + u[i + 1]) / 4
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)


def ABC076D():
	N = int(input())
	t = list(map(int, input().split()))
	a = []
	for i in t:
		a.append(i * 2)
	t = a
	v = list(map(int, input().split()))
	speed_lim = [0]
	speed_list = [0 for i in range(sum(t) + 1)]
	for i in range(N):
		for j in range(t[i]):
			speed_lim.append(v[i])
	for i in range(1, sum(t) + 1):
		speed_list[i] = speed_list[i - 1] + 0.5
		if speed_list[i] > speed_lim[i]:
			speed_list[i] = speed_lim[i]
	speed_list[-1] = 0
	for i in range(sum(t) - 1, -1, -1):
		speed_list[i] = min(speed_list[i + 1] + 0.5, speed_list[i])
		if speed_list[i] > speed_lim[i + 1]:
			speed_list[i] = speed_lim[i + 1]
	ans = 0
	for i in speed_list:
		ans += i
	print(ans / 2)
ABC076D()


N = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
tt = 0
lim = []
for i in range(N):
	for j in range(ts[i]):
		lim.append(vs[i])
		tt += 1
up = [False for i in range(tt)]
v = 0
for i in range(tt):
	if lim[i] > v:
		v += 1
		lim[i] = v
		up[i] = True
	else:
		v = lim[i]
down = [False for i in range(tt)]
v = 0
for i in range(tt - 1, -1, -1):
	if lim[i] > v:
		v += 1
		if lim[i] > v:
			up[i] = False
		lim[i] = v
		down[i] = True
	else:
		v = lim[i]
ans = 0
for i in range(tt):
	ans += lim[i]
	if up[i] and down[i]:
		ans -= 0.75
	elif up[i] or down[i]:
		ans -= 0.5
print(ans)


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)


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()))
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 += 0.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 += 0.5
		R[tt] = min(v, xv)
	xt += t
	xv = min(v, xv)
print(sum(map(min, L, R[::-1])) / 2)


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)


def inpl():
	return [int(i) for i in input().split()]

def trapezoid(St, En, H, i):
	if St + H[i][0] >= En - H[i][0]:
		return (En - St) ** 2 / 4
	result = H[i][0] * (En - St - H[i][0])
	if H[i][1] > St + H[i][0]:
		result += trapezoid(St + H[i][0], min(En - H[i][0], H[i][1]), H, i + 1)
	if H[i][2] < En - H[i][0]:
		result += trapezoid(max(St + H[i][0], H[i][2]), En - H[i][0], H, i + 1)
	return result
N = int(input())
t = inpl()
v = inpl()
H = [[v[0], 0, t[0]]]
for i in range(1, N):
	H.append([v[i], H[i - 1][2], H[i - 1][2] + t[i]])
H.append([float('inf'), 0, 0])
H.sort(key=lambda x: x[0])
for i in range(N, 0, -1):
	H[i][0] -= H[i - 1][0]
print(trapezoid(0, sum(t), H, 0))


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)


N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
from_start = [0]
for i in range(N):
	for s in range(2 * t[i]):
		from_start += [min(from_start[-1] + 1, 2 * v[i])]
to_goal = [0]
t.reverse()
v.reverse()
for i in range(N):
	for s in range(2 * t[i]):
		to_goal += [min(to_goal[-1] + 1, 2 * v[i])]
to_goal.reverse()
velo = []
for s in range(2 * sum(t) + 1):
	velo += [min(from_start[s], to_goal[s])]
print(sum(velo) / 4 - (velo[0] + velo[-1]) / 8)


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)


from itertools import chain

def main():
	N = int(input())
	t = list(map(int, input().split()))
	v = list(map(int, input().split()))
	vmax = list(chain.from_iterable(([i] * (2 * j) for (i, j) in zip(v, t))))
	vmax = [min(v1, v2) for (v1, v2) in zip([0] + vmax, vmax + [0])]
	now = 0
	for i in range(1, len(vmax)):
		vmax[i] = min(vmax[i], now + 0.5)
		now = vmax[i]
	now = 0
	for i in range(len(vmax) - 1, 0, -1):
		vmax[i] = min(vmax[i], now + 0.5)
		now = vmax[i]
	ans = 0
	for i in range(len(vmax) - 1):
		if vmax[i] == vmax[i + 1]:
			ans += 0.5 * vmax[i]
		else:
			ans += (vmax[i] + vmax[i + 1]) * 0.5 / 2
	print(ans)
main()


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)


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

def main():

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

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)


n = int(input())
t = list(map(int, input().split()))
L = list(map(int, input().split()))
m = sum(t)
d = [0 for _ in range(m + 1)]
v = 0
s = 0
for i in range(n):
	for j in range(t[i]):
		d[s] = v
		v = min(v + 1, L[i])
		s += 1
ans = 0
v = 0
s = m
for i in range(n - 1, -1, -1):
	for j in range(t[i]):
		d[s] = v
		if v == d[s - 1] and v < L[i]:
			ans += 0.25
		v = min(v + 1, L[i], d[s - 1])
		s -= 1
for i in range(1, m + 1):
	if d[i] == d[i - 1]:
		ans += d[i]
	elif d[i] > d[i - 1]:
		ans += d[i] - 0.5
	elif d[i] < d[i - 1]:
		ans += d[i] + 0.5
print(ans)


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

def interval(t):
	pass
N = int(input())
T = spaceinput()
v = spaceinput()
Tmax = 0
for i in range(N):
	Tmax += T[i]
mv = {}
frange = [x for x in range(2 * Tmax + 1)]
k = 0
sT = T[0]
d = 0.5
mv[0] = 0
for t in [x / 2 for x in range(1, 2 * Tmax)]:
	if sT < t:
		k += 1
		if k < len(T):
			sT += T[k]
		else:
			break
	mv[t] = min(v[k], mv[t - 0.5] + d)
mv[Tmax] = 0
k = N - 1
sT = Tmax - T[-1]
for t in reversed([x / 2 for x in range(1, 2 * Tmax)]):
	if sT > t:
		k -= 1
		sT -= T[k]
	mv[t] = min(v[k], mv[t], mv[t + d] + d)
res = 0
k = 0
sT = T[0]
for t in [x / 2 for x in range(1, 2 * Tmax)]:
	if sT < t:
		if t == Tmax - 1:
			break
		k += 1
		if k < len(T):
			sT += T[k]
	res += mv[t] * 0.5
print(res)


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 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()))
v = [0] * (sum(T) * 2 + 1)
(t, Ti) = (0, 0)
for i in range(N):
	Ti += T[i] * 2
	v[t] = min(v[t], V[i])
	while t < Ti:
		if v[t] < V[i]:
			v[t + 1] = v[t] + 0.5
		else:
			v[t + 1] = min(v[t], V[i])
		t += 1
sumT = sum(T) * 2
v[sumT] = 0
(t, Ti) = (sumT, sumT)
for i in range(N):
	Ti -= T[N - i - 1] * 2
	while t > Ti:
		if v[t - 1] > v[t] + 0.5:
			v[t - 1] = v[t] + 0.5
		t -= 1
Ans = 0
for i in range(sumT):
	Ans += (v[i] + v[i + 1]) * 0.5 / 2
print(Ans)


n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
t_cumsum = [t[0]]
for i in range(1, n):
	t_cumsum.append(t[i] + t_cumsum[i - 1])
v_max = [0]
idx = 0
for i in range(1, 2 * sum(t) + 1):
	time = i / 2
	if time < t_cumsum[idx]:
		v_max.append(v[idx])
	elif time == t_cumsum[-1]:
		v_max.append(0)
	else:
		v_max.append(min(v[idx], v[idx + 1]))
		idx += 1
vs = [0] * len(v_max)
for i in range(1, len(v_max)):
	vs[i] = min(vs[i - 1] + 0.5, v_max[i])
for i in range(len(v_max) - 2, -1, -1):
	vs[i] = min(vs[i], vs[i + 1] + 0.5, v_max[i])
ans = 0
for (v0, v1) in zip(vs[:-1], vs[1:]):
	ans += (v0 + v1) / 2 * 0.5
print(ans)


N = int(input())
T = [int(t) for t in input().split()]
V = [int(v) for v in input().split()]
T.append(0)
V.append(0)
time = [0] * (N + 1)
time[0] = T[0]
for i in range(N):
	time[i + 1] = time[i] + T[i + 1]
L = [0] * (2 * time[-1] + 1)
i = 0
t = 0.5
while t <= time[-1]:
	num = V[i]
	if t == time[i]:
		i += 1
		num = min(num, V[i])
	v = L[int(2 * t) - 1] + 0.5
	while v > num:
		v -= 0.5
	for j in range(int(i) + 1, N + 1):
		if v - 0.5 - V[j] > time[j - 1] - t:
			v -= 1
		elif v - V[j] > time[j - 1] - t:
			v -= 0.5
	L[int(2 * t)] = v
	t += 0.5
ans = 0
for i in range(len(L) - 1):
	if L[i + 1] > L[i]:
		ans += L[i] * 0.5 + 0.25
	elif L[i + 1] == L[i]:
		ans += L[i] * 0.5
	else:
		ans += L[i] * 0.5 - 0.25
print(ans)


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)


from bisect import bisect_left, bisect_right
from itertools import accumulate
N = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
Ts = list(accumulate([0] + ts))

def solve(begin, end, v):
	if begin >= end:
		return 0
	if begin + 1 == end:
		if v < vs[bisect_right(Ts, begin) - 1]:
			return 0.25
		else:
			return 0
	min_v = min(vs[bisect_right(Ts, begin) - 1:bisect_left(Ts, end)])
	if min_v == v:
		ret = 0
		last = begin
		for i in range(bisect_right(Ts, begin) - 1, bisect_left(Ts, end)):
			if v == vs[i]:
				ret += solve(last, Ts[i], v)
				last = Ts[i + 1]
		ret += solve(last, end, v)
		return ret
	else:
		return end - begin - 1 + solve(begin + 1, end - 1, v + 1)
print(solve(0, Ts[-1], 0))


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()


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)


from itertools import chain
N = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
vm = list(chain.from_iterable(([v] * (2 * t) for (t, v) in zip(ts, vs))))
vm = [min(v1, v2) for (v1, v2) in zip([0] + vm, vm + [0])]
T = len(vm)
for i in range(T - 1):
	vm[i + 1] = min(vm[i + 1], vm[i] + 0.5)
for i in range(T - 1)[::-1]:
	vm[i] = min(vm[i], vm[i + 1] + 0.5)
print(sum(((v1 + v2) / 4 for (v1, v2) in zip(vm, vm[1:]))))


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())
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[:]
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
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)


N = int(input())
T = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]
Ts = sum(T)
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]
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 = 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]
			VV[j] = min(VV[j], a + V[i])
print(sum(VV) / 2)


N = int(input())
t = list(map(int, input().split()))
T = [0]
tot = 0
for i in range(len(t)):
	tot += t[i]
	T.append(tot)
T = list(map(lambda x: x * 2, T))
v = list(map(int, input().split()))
v.append(0)
curv = 0
dist = 0
curt = 0
for i in range(N):
	for _ in range(T[i], T[i + 1]):
		prev = curv
		ok = 1
		for j in range(N - i):
			if T[i + j + 1] / 2.0 - curt > curv - v[i + j + 1]:
				continue
			else:
				ok = 0
				break
		if ok == 1:
			if curv < v[i]:
				curv += 0.5
		elif ok == 0:
			curv -= 0.5
		curt += 0.5
		dist += (prev + curv) / 4.0
print(dist)


from itertools import accumulate
N = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
accTs = list(accumulate(ts))
sumT = accTs[-1]
vMaxs = [[] for i in range(N + 2)]
for (i, (v, l, r)) in enumerate(zip(vs + [0, 0], [0] + accTs[:-1] + [0, sumT], accTs + [0, sumT])):
	vms = [v + l - t / 2 for t in range(0, l * 2)] + [v] * ((r - l) * 2 + 1) + [v + t / 2 - r for t in range(r * 2 + 1, sumT * 2 + 1)]
	vMaxs[i] = vms
vMaxs = list(map(min, *vMaxs))
print(sum(vMaxs) / 2)


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
tmax = sum(T)
Vmax = max(V)
dp = [[-1 * float('inf') for _ in range(Vmax + 1)] for _ in range(tmax)]
dp[0][0] = 0
i = 0
j = 0
vmax = V[0]
for t in range(1, tmax):
	i += 1
	if i == T[j] + 1:
		i = 1
		j += 1
		vmax = V[j]
	for v in range(1, vmax + 1):
		acc = dp[t - 1][v - 1] + v - 0.5 if v != 0 else 0.5
		if v < vmax:
			same = dp[t - 1][v] + v + 0.25
			bra = dp[t - 1][v + 1] + v + 0.5
		else:
			same = dp[t - 1][v] + v
			bra = -float('inf')
		dp[t][v] = max(acc, same, bra)
if tmax == 1:
	print(0.25)
else:
	print(dp[-1][1] + 0.5)


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)


from itertools import accumulate
U = 300
n = int(input())
T = [0] + list(map(lambda x: int(x) * 2, input().split()))
V = list(map(lambda x: int(x) * 2, input().split())) + [0]
S = sum(T)
M = [0] * (S + 1)
K = list(accumulate(T))
for i in range(n):
	for j in range(K[i] + 1, K[i + 1]):
		M[j] = V[i]
	M[K[i + 1]] = min(V[i], V[i + 1])
dp = [[-float('inf')] * (U + 1) for _ in range(S + 1)]
dp[0][0] = 0
for t in range(1, S + 1):
	for v in range(U + 1):
		if v > M[t]:
			continue
		dp[t][v] = dp[t - 1][v] + v
		if v > 0:
			dp[t][v] = max(dp[t][v], dp[t - 1][v - 1] + (2 * v - 1) / 2)
		if v < U:
			dp[t][v] = max(dp[t][v], dp[t - 1][v + 1] + (2 * v + 1) / 2)
ans = max(dp[S]) / 4
print(ans)


n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
v.append(0)
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]
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]
	ans += now * t2
	ans += now * t3 - t3 * t3 / 2
	now -= t3
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
	elif 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)


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)
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)


ADJ = 10 ** 2
n = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
for i in range(n):
	ts[i] *= ADJ
	vs[i] *= ADJ
tt = sum(ts)
vss = [0] * tt
j = 0
cnt = 0
for i in range(tt):
	vss[i] = vs[j]
	cnt += 1
	if cnt == ts[j]:
		j += 1
		cnt = 0
max_speed = 1
max_speeds = [0] * tt
for i in reversed(range(tt - 1)):
	max_speeds[i] = min(max_speed, vss[i], vss[i + 1], max_speeds[i + 1] + 1)
	max_speed += 1
cv = 0
for i in range(tt):
	if cv < max_speeds[i]:
		cv += 1
	elif cv == max_speeds[i]:
		pass
	else:
		cv -= 1
	vss[i] = cv
res = 0
for i in range(tt):
	if i == 0:
		res += vss[i] / 2
	elif vss[i] >= vss[i - 1]:
		res += vss[i - 1] + (vss[i] - vss[i - 1]) / 2
	else:
		res += (vss[i - 1] - vss[i]) / 2 + vss[i]
print(res / ADJ / ADJ)


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

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	N = int(next(tokens))
	t = [int(next(tokens)) for _ in range(N)]
	v = [int(next(tokens)) for _ in range(N)]
	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(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)


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:]))))


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))
	t = [int(next(tokens)) for _ in range(N)]
	v = [int(next(tokens)) for _ in range(N)]
	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 = [0] * (N + 1)
for i in range(N):
	T[i + 1] = T[i] + t[i]

def f(i, t):
	if T[i] <= t <= T[i + 1]:
		return v[i]
	if t < T[i]:
		return v[i] + (T[i] - t)
	else:
		return v[i] + (t - T[i + 1])
limit = [0] * (T[-1] * 2 + 1)
for t in range(1, T[-1] * 2 + 1):
	limit[t] = min(min((f(i, t / 2) for i in range(N))), t / 2, T[-1] - t / 2)
print(sum(limit) / 2)


N = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
maxv = [0] * (sum(ts) * 2 + 1)
dp = [0] * (sum(ts) * 2 + 1)
ima = 1
for i in range(len(ts)):
	k = ts[i]
	if i != 0:
		maxv[ima - 1] = min(vs[i], vs[i - 1])
	for j in range(k * 2):
		maxv[j + ima] = vs[i]
	ima += k * 2
maxv[-1] = 0
for i in range(1, len(dp)):
	dp[i] = min(dp[i - 1] + 0.5, maxv[i])
for i in range(len(dp) - 1, 0, -1):
	dp[i - 1] = min(dp[i] + 0.5, maxv[i - 1], dp[i - 1])
ans = sum(dp) / 2
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 = [int(i) for i in input().split()]
t_Table = [0]
for i in range(N):
	t_Table.append(t_Table[i] + t_List[i])
v_List = [int(i) for i in input().split()]
v_List.append(0)
Class = 0
t = 0
v = 0
L = 0
check = 0
while t <= t_Table[-1]:
	for i in range(Class + 1, N + 1):
		if t_Table[i] != t:
			if (v_List[i] - v) / (t_Table[i] - t) == -1:
				L += v / 2 - 1 / 8
				v += -0.5
				check = -1
				break
	if check != -1:
		if v == v_List[Class]:
			L += v / 2
		else:
			L += v / 2 + 1 / 8
			v += 0.5
	t += 0.5
	if t_Table[Class + 1] == t and Class <= N - 2:
		Class += 1
		check = 0
print(L)


def velsup(a, b, c, x):
	if a <= x <= b:
		return c
	elif x < a:
		return a - x + c
	else:
		return x - b + c
N = int(input())
t = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]
S = [0 for i in range(N + 1)]
for i in range(N):
	S[i + 1] = t[i] + S[i]
TT = S[N]
vt = [0 for i in range(2 * TT + 1)]
for tt in range(TT * 2 + 1):
	ta = tt / 2
	va = min(velsup(-1, 0, 0, ta), velsup(TT, TT + 1, 0, ta))
	for i in range(N):
		va = min(va, velsup(S[i], S[i + 1], v[i], ta))
	vt[tt] = va
ans = 0
for i in range(2 * TT):
	ans += (vt[i] + vt[i + 1]) * 0.25
print(ans)


def input_num_list():
	return list(map(int, input().split()))
n = int(input())
t = input_num_list()
T = sum(t)
v = input_num_list()
maxv = [100 for _ in range(2 * T + 1)]
maxv[0] = 0
maxv[2 * T] = 0
(t_l, t_r) = (0, 0)
for i in range(n):
	t_l = t_r
	t_r += t[i]
	vv = v[i]
	for j in range(2 * t_l, 2 * t_r + 1):
		maxv[j] = min(maxv[j], vv)
i = 1
while i <= 2 * T:
	maxv[i] = min(maxv[i], maxv[i - 1] + 0.5)
	i += 1
i = 2 * T - 1
while i >= 0:
	maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)
	i -= 1
ans = 0
i = 0
while i <= 2 * T - 1:
	ans += 0.25 * (maxv[i] + maxv[i + 1])
	i += 1
print(ans)


n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
T = sum(t)
d = [0 for _ in range(2 * T + 2)]
l = [0]
for i in range(n):
	for j in range(t[i] * 2):
		l.append(v[i])
l.append(0)
for i in range(2 * T):
	d[i + 1] = min(d[i] + 0.5, l[i + 1])
l.reverse()
d2 = [0 for _ in range(2 * T + 2)]
for i in range(2 * T):
	d2[i + 1] = min(d2[i] + 0.5, l[i])
d2.reverse()
l.reverse()
d3 = [0 for _ in range(2 * T + 2)]
for i in range(2 * T + 1):
	d3[i] = min(d[i], d2[i])
res = 0
for i in range(T * 2):
	res += (d3[i] + d3[i + 1]) / 4
print(res)


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)


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()


N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
N_INF = -10 ** 15
DP = [[N_INF] * 102 for _ in range(100 * 200 + 2)]
DP[0][0] = 0
time = 1
for i in range(N):
	for j in range(time, time + t[i]):
		for k in range(0, v[i] + 1):
			if k == 0:
				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:
				DP[j][k] = max(DP[j - 1][k - 1] + k - 1 / 2, DP[j - 1][k] + k)
	time += t[i]
print(DP[time - 1][0])


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)


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
	elif 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
			elif 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)


def solve():
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	tlist = [0]
	for val in arr1:
		tlist.append(tlist[-1] + val)
	t = tlist[-1]
	ans = 0
	for i in range(1, 2 * t):
		tt = i / 2
		tmp = 10 ** 18
		for j in range(n):
			if tt <= tlist[j]:
				tmp = min(tmp, arr2[j] + (tlist[j] - tt))
			elif tlist[j + 1] <= tt:
				tmp = min(tmp, arr2[j] + (tt - tlist[j + 1]))
			else:
				tmp = min(tmp, arr2[j])
		tmp = min(tmp, tt)
		tmp = min(tmp, t - tt)
		ans += tmp
	print(ans / 2)
solve()


import sys
from itertools import accumulate
input = sys.stdin.readline
N = int(input())
T = [0] + list(map(int, input().split()))
V = list(map(int, input().split()))
T = [2 * t for t in T]
V = [2 * v for v in V]
cT = list(accumulate(T))
fs = [lambda x: x, lambda x: -x + cT[-1]]
for i in range(N):
	fs.append(lambda x, i=i: max(V[i], -x + cT[i] + V[i], x - cT[i + 1] + V[i]))
last = cT[-1]
vs = []
for x in range(last + 1):
	temp = 10 ** 10
	for f in fs:
		temp = min(temp, f(x))
	vs.append(temp)
ans = (sum(vs) + sum(vs[1:-1])) / 8
print(ans)


import copy
N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
L = [0]
for i in range(N):
	a = [v[i] for j in range(t[i] * 2)]
	L += a
X = []
for i in range(1, len(L)):
	if L[i - 1] > L[i]:
		X.append(i)
for i in X:
	L[i - 1] = L[i]
L[-1] = 0
S = copy.deepcopy(L)
for i in range(1, len(L)):
	if L[i - 1] < L[i]:
		for j in range(10 ** 5):
			if S[i - 1] + 0.5 * j > 400 or i - 1 + j > len(L) - 1:
				break
			else:
				S[i - 1 + j] = min(S[i - 1] + 0.5 * j, S[i - 1 + j])
	elif L[i - 1] > L[i]:
		for j in range(10 ** 5):
			if S[i] + 0.5 * j > 400 or i < j:
				break
			else:
				S[i - j] = min(S[i] + 0.5 * j, S[i - j])
ans = 0
for i in range(1, len(S)):
	ans += (S[i - 1] + S[i]) / 2
print(ans / 2)


n = int(input())
ts = [int(c) for c in input().split()]
vs = [int(c) for c in input().split()]
t = sum(ts)
dp = [[-10 ** 10 for _ in range(101)] for _ in range(t + 1)]
dp[0][0] = 0.0
mvs = []
for (dt, mv) in zip(ts, vs):
	for st in range(dt):
		mvs.append(mv)
mvs.append(0)
for ct in range(t):
	mv = mvs[ct]
	for cv in range(mv + 1):
		endmv = min(mv, mvs[ct + 1])
		for dv in [-1, 0, 1]:
			nv = cv + dv
			if 0 <= nv <= endmv:
				dp[ct + 1][nv] = max(dp[ct][cv] + (cv + nv) / 2, dp[ct + 1][nv])
		if mv >= cv + 1 and cv <= endmv:
			dp[ct + 1][cv] = max(dp[ct + 1][cv], dp[ct][cv] + cv + 0.25)
print(dp[t][0])


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())
ts = [int(i) for i in input().split()]
vmax = [int(i) for i in input().split()]
s = []
v = 0
for i in range(N):
	v = min(v, vmax[i])
	for t in range(ts[i]):
		if v < vmax[i]:
			s.append(v + 0.5)
			v += 1
		else:
			s.append(v)
ts = ts[::-1]
vmax = vmax[::-1]
s = s[::-1]
v = 0
count = 0
for i in range(N):
	v = min(v, vmax[i])
	for t in range(ts[i]):
		if v < vmax[i]:
			if s[count] == v + 0.5:
				s[count] = v + 0.25
			else:
				s[count] = min(v + 0.5, s[count])
			v += 1
		else:
			s[count] = min(v, s[count])
		count += 1
print(sum(s))


import sys
sys.setrecursionlimit(2147483647)
INF = float('inf')
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()

def resolve():
	n = int(input())
	T = [0] + list(map(int, input().split()))
	for i in range(n):
		T[i + 1] += T[i]
	V = list(map(int, input().split()))

	def f(t):
		res = INF
		res = min(res, t)
		res = min(res, -t + T[-1])
		for i in range(1, n + 1):
			if t < T[i - 1]:
				res = min(res, -t + T[i - 1] + V[i - 1])
			elif t <= T[i]:
				res = min(res, V[i - 1])
			else:
				res = min(res, t - T[i] + V[i - 1])
		return res
	ans = 0
	for t in range(2 * T[-1]):
		ans += (f(t / 2) + f((t + 1) / 2)) / 4
	print(ans)
resolve()


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((0.5, 0), 0, st + 1)
for (u, w) in zip(t, v):
	u += u + i
	add_line((0, w), i, u)
	add_line((-0.5, w + i / 2), 0, i + 1)
	add_line((0.5, w - u / 2), u, st + 1)
	(i, b) = (u, w)
add_line((-0.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()))
time = 0
sum_t = sum(t)
velo_cap = [float('inf')] * (2 * sum_t + 1)
for i in range(N):
	start_t = time
	goal_t = time + 2 * t[i]
	for s in range(0, 2 * sum_t + 1):
		if s < start_t:
			velo_cap[s] = min(velo_cap[s], 2 * v[i] + (start_t - s))
		elif s < goal_t:
			velo_cap[s] = min(velo_cap[s], 2 * v[i])
		else:
			velo_cap[s] = min(velo_cap[s], 2 * v[i] + (s - goal_t))
	time += 2 * t[i]
for s in range(2 * sum_t + 1):
	velo_cap[s] = min(velo_cap[s], 2 * sum_t - s, s)
print(sum(velo_cap) / 4 - (velo_cap[0] + velo_cap[-1]) / 8)


n = int(input())
t = list(map(int, input().split())) + [0]
v = list(map(int, input().split())) + [0]
m = sum(t) * 2
g = [10 ** 10] * (m + 1)
l = [(0, 0, 0)]
for (x, y) in zip(t, v):
	l.append((l[-1][1], l[-1][1] + x * 2, y))
for (x, y, c) in l:
	for i in range(m + 1):
		d = c
		if i < x:
			d += (x - i) * 0.5
		elif y < i:
			d += (i - y) * 0.5
		if g[i] > d:
			g[i] = d
print(sum(g) / 2)


INF = 1 << 30
N = int(input())
t = [int(_) for _ in input().split()]
st = [0] * (N + 1)
for i in range(N):
	st[i + 1] = t[i] + st[i]
T = st[N]
st.append(T)
v = [int(_) for _ in input().split()]
v.insert(0, 0)
v.append(0)
l = [0]
now = 0.5
ind = 1
while now < T:
	v1 = INF
	v2 = INF
	for j in range(ind):
		v1 = min(v1, v[j] + now - st[j])
	for j in range(ind, N + 1):
		v2 = min(v2, v[j + 1] - now + st[j])
	l.append(min(v[ind], v1, v2))
	now += 0.5
	if now >= st[ind]:
		ind += 1
l.append(0)
res = 0
for i in range(len(l)):
	res += l[i] / 2
print(res)


N = int(input())
T = list(map(int, input().split())) + [0]
V = list(map(int, input().split())) + [0]
now = 0
end = min(V[0], now + T[0])
ans = 0
for i in range(N):
	t = T[i]
	v = V[i]
	end = min(v, now + t)
	plus = 0
	for j in range(i, N):
		end = min(end, V[j + 1] + plus)
		plus += T[j + 1]
	(x, y) = ((end + t - now) / 2, (end + t + now) / 2)
	if y <= v:
		ans += (now + y) * x / 2 + (end + y) * (t - x) / 2
	else:
		ans += (v + now) * (v - now) / 2 + (v + end) * (v - end) / 2 + v * (end - 2 * v + t + now)
	now = end
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 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 = [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)


from itertools import accumulate as ac
n = int(input()) + 2
t = [0] + list(map(int, input().split())) + [0]
v = [0] + list(map(int, input().split())) + [0]
s = [0] + list(ac(t))

def f(i, x):
	if s[i] <= x <= s[i + 1]:
		return v[i]
	elif x < s[i]:
		return v[i] + s[i] - x
	else:
		return v[i] + x - s[i + 1]
c = float('INF')
for i in range(n):
	c = min(c, f(i, 0))
e = 0
for i in range(1, 2 * s[-1] + 1):
	i = i / 2
	d = float('INF')
	for j in range(n):
		d = min(d, f(j, i))
	e += 0.25 * (c + d)
	c = d
print(e)


def main():
	N = int(input())
	T = list(map(int, input().split()))
	V = list(map(int, input().split()))
	C = [0] * (N + 1)
	for i in range(N - 1):
		C[i + 1] = min(V[i], V[i + 1])
	for _ in range(N):
		for i in range(N):
			left = C[i]
			right = C[i + 1]
			C[i] = min(C[i], right + T[i])
			C[i + 1] = min(C[i + 1], left + T[i])
	ans = 0
	for i in range(N):
		if V[i] - C[i] + (V[i] - C[i + 1]) < T[i]:
			lx = V[i] - C[i]
			rx = V[i] - C[i + 1]
			ans += (C[i] + V[i]) * lx / 2 + (C[i + 1] + V[i]) * rx / 2 + V[i] * (T[i] - lx - rx)
		else:
			M = max(C[i], C[i + 1])
			m = min(C[i], C[i + 1])
			x = (T[i] - (M - m)) / 2
			ans += (M + M + x) * x / 2 + (m + M + x) * (x + (M - m)) / 2
	print(ans)
main()


def f(v, t, now):
	res = now
	s = 0
	for i in range(len(t) - 1):
		s += t[i]
		if s - t[i] >= now:
			res = min(res, v[i] + s - t[i] - now)
		elif s >= now >= s - t[i]:
			res = min(res, v[i])
		else:
			res = min(res, v[i] + now - s)
	res = min(res, s - now)
	return max(res, 0)
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
t.append(0)
v.append(0)
ans = []
for i in range(sum(t) + 1):
	ans.append(f(v, t, i))
	ans.append(f(v, t, i + 0.5))
r = 0
for i in range(len(ans) - 1):
	r += (ans[i] + ans[i + 1]) / 4
print(r)


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)


from itertools import accumulate
import sys
input = sys.stdin.readline
N = int(input())
t = list(accumulate([0] + list(map(int, input().split())) + [0]))
v = [0] + list(map(int, input().split())) + [0]
prev = 0
ans = 0
T = t[-1]
for i in range(0, 2 * T + 1):
	i /= 2
	cur = i
	for j in range(N + 1):
		l = t[j]
		r = t[j + 1]
		u = v[j + 1]
		if i < l:
			cur = min(cur, u + (l - i))
		elif i > r:
			cur = min(cur, u + (i - r))
		else:
			cur = min(cur, u)
	ans += (prev + cur) / 4
	prev = cur
print(ans)


import numpy as np
N = int(input())
t = np.array(['0'] + input().split(), np.int64)
v = list(map(int, input().split()))
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())


def calc(left, right, time, vmax):
	if left <= time and time <= right:
		return vmax
	elif time < left:
		return vmax + left - time
	else:
		return vmax + time - right
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
tlst = [[0, t[0]]]
for i in range(1, n):
	start = tlst[-1][1]
	stop = start + t[i]
	tlst.append([start, stop])
tmax = sum(t)
vnow = 0
ans = 0
for i in range(1, 2 * tmax + 1):
	time = 0.5 * i
	vmin = 10 ** 9
	for j in range(n):
		(left, right) = (tlst[j][0], tlst[j][1])
		vmax = v[j]
		vmin = min(vmin, calc(left, right, time, vmax))
	vmin = min(vmin, calc(0, 0, time, 0))
	vmin = min(vmin, calc(tmax, tmax, time, 0))
	ans += 0.25 * (vmin + vnow)
	vnow = vmin
print(ans)


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
from itertools import accumulate as acm
T = [0] + list(acm(T))
V = V + [0]
nowSp = 0
dis = 0
nowTime = 0
from bisect import bisect_left as bl
while nowTime < T[-1]:
	nowTime += 0.5
	minV = min((T[i] - nowTime + V[i] for i in range(len(T)) if T[i] >= nowTime))
	idx = bl(T, nowTime) - 1
	minV = min(minV, V[idx])
	if minV > nowSp:
		minV = min(minV, nowSp + 0.5)
	if minV < nowSp:
		minV = min(minV, nowSp - 0.5)
	dis += (nowSp + minV) / 2 * 0.5
	nowSp = minV
print(dis)


from itertools import chain
n = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
va = list(chain.from_iterable(([v] * (2 * t) for (t, v) in zip(ts, vs))))
va = [min(v1, v2) for (v1, v2) in zip([0] + va, va + [0])]
lt = len(va)
va[-1] = 0
pv = 0
for ct in range(1, lt):
	va[ct] = pv = min(va[ct], pv + 0.5)
pv = 0
for ct in range(lt - 1, 0, -1):
	va[ct] = pv = min(va[ct], pv + 0.5)
print(sum(((v1 + v2) / 4 for (v1, v2) in zip(va, va[1:]))))


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)


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 math
import numpy as np
import decimal
import collections
import itertools
import sys
import random

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

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
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

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)

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

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)

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

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

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())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
T = [0 for i in range(n)]
T[0] = t[0]
for i in range(n - 1):
	T[i + 1] = T[i] + t[i + 1]
INF = float('inf')
V = [INF for i in range(2 * T[n - 1] + 1)]
for i in range(2 * T[n - 1] + 1):
	V[i] = min(V[i], 0.5 * i)
	V[i] = min(V[i], T[n - 1] - 0.5 * i)
for vi in range(n):
	for ti in range(2 * T[n - 1] + 1):
		if vi == 0:
			if ti <= T[0] * 2:
				V[ti] = min(V[ti], v[0])
			else:
				V[ti] = min(V[ti], v[0] + ti * 0.5 - T[0])
		elif ti <= T[vi - 1] * 2:
			V[ti] = min(V[ti], v[vi] + T[vi - 1] - ti * 0.5)
		elif T[vi - 1] * 2 <= ti and ti <= T[vi] * 2:
			V[ti] = min(V[ti], v[vi])
		else:
			V[ti] = min(V[ti], v[vi] + (ti * 0.5 - T[vi]))
ans = 0
for i in range(2 * T[n - 1]):
	ans += (V[i] + V[i + 1]) * 0.5 * 0.5
print(ans)


n = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
b = 2
bg = 1.0 / b
M = []
for i in range(n):
	for j in range(T[i] * b):
		M.append(V[i])
R = [0] + T[:]
for i in range(n):
	R[i + 1] += R[i]
for i in range(n):
	le = R[i] * b
	ri = R[i + 1] * b
	j = 0
	if i - 1 >= 0 and V[i - 1] > V[i]:
		while le >= 0:
			M[le] = min(M[le], V[i] + j * bg)
			j += 1
			le -= 1
	j = 0
	if i + 1 < n and V[i + 1] > V[i]:
		while ri < len(M):
			M[ri] = min(M[ri], V[i] + j * bg)
			j += 1
			ri += 1
for i in range(len(M)):
	M[i] = min(i * bg, (len(M) - i) * bg, M[i])
M += [0]
ans = 0
for i in range(len(M) - 1):
	ans += (M[i] + M[i + 1]) * bg * 0.5
print(ans)


from bisect import bisect_left
n = int(input())
t = [0] + [int(i) for i in input().split()] + [0]
v = [int(i) for i in input().split()] + [0]

def f(x, v, t1, t2):
	if x < t1:
		return v + (t1 - x)
	elif t1 <= x <= t2:
		return v
	else:
		return v + (x - t2)
for i in range(1, n + 2):
	t[i] += t[i - 1]
(T, ans) = (t[-1], 0)
for i in range(2 * T + 1):
	num = min(i / 2, T - i / 2)
	for j in range(max(0, bisect_left(t, i / 2 - 100) - 1), n + 1):
		if i / 2 < t[j] - 100:
			break
		num = min(num, f(i / 2, v[j], t[j], t[j + 1]))
	ans += num / 2
print(ans)


N = int(input())
T = [1] + list(map(int, input().split())) + [1]
V = [0] + list(map(int, input().split())) + [0]
T = list(map(lambda x: x * 2, T))
V = list(map(lambda x: x * 2, V))
X = [i for i in range(sum(T) + 1)]
C = [0]
X[-1] = 0
for i in range(len(T)):
	C.append(C[i] + T[i])
for i in range(N + 2):
	for j in range(C[i + 1]):
		if j >= C[i]:
			X[j] = min(X[j], V[i])
		else:
			X[j] = min(X[j], V[i] + C[i] - j - 1)
for i in range(len(X) - 1):
	X[i + 1] = min(X[i + 1], X[i] + 1)
print(sum(X) / 4)


N = int(input())
tli = [int(it) * 2 for it in input().split()]
vli = [int(it) * 2 for it in input().split()]
vmax = [0]
for i in range(len(tli)):
	tmp = vmax.pop()
	vmax.append(min(tmp, vli[i]))
	vmax.extend([vli[i]] * tli[i])
vmax[-1] = 0
vmax[0] = 0
T = len(vmax) - 1
for j in range(1000):
	for i in range(T):
		vmax[i + 1] = min(vmax[i] + 1, vmax[i + 1])
	for i in range(T, 0, -1):
		vmax[i - 1] = min(vmax[i] + 1, vmax[i - 1])
	if j == 0:
		pass
print(0.25 * sum(vmax))


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 = [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()))
T = [0, t[0]]
for i in range(n - 1):
	T.append(T[i + 1] + t[i + 1])
L = [[] for i in range(2 * sum(t))]
for i in range(2 * sum(t)):
	for j in range(n):
		if T[j] <= i / 2 <= T[j + 1]:
			x = v[j]
		elif i / 2 < T[j]:
			x = v[j] + abs(i / 2 - T[j])
		else:
			x = v[j] + abs(i / 2 - T[j + 1])
		L[i].append(x)
for i in range(2 * sum(t)):
	L[i].append(i / 2)
	L[i].append(sum(t) - i / 2)
for i in range(2 * sum(t)):
	L[i] = min(L[i])
ans = 0
for i in range(2 * sum(t)):
	if i == 2 * sum(t) - 1:
		ans += L[i] * 0.25
	else:
		ans += (L[i] + L[i + 1]) * 0.25
print(ans)


N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
v.append(0)
interval = 0.5
total_t = sum(t)
now_t = 0
now_v = 0
T = [sum(t[:i]) for i in range(1, N + 1)]
now_n = 0
d = 0
d_int = 0
while now_t < total_t:
	(nxt_t, nxt_v) = (T[now_n], v[now_n + 1])
	(delta_t, delta_v) = (nxt_t - now_t, nxt_v - now_v)
	rest_t = [T[i] - now_t for i in range(N)]
	if now_v < v[now_n]:
		if delta_t + delta_v == 0:
			a = -1
		else:
			a = 1
	elif now_v == v[now_n]:
		if delta_t + delta_v == 0:
			a = -1
		else:
			a = 0
	for i in range(N):
		rest = rest_t[i]
		if rest > 0:
			d_v = now_v - v[i + 1]
			if rest == d_v:
				a = -1
	d_int += 2 * int(now_v * 2) + a
	d += now_v * interval + 1 / 2 * a * interval * interval
	now_t += interval
	now_v += a * interval
	if now_t == T[now_n]:
		now_n += 1
print(d)


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())
tlist = list(map(int, input().split()))
vlist = list(map(int, input().split()))

def const(l, r, v, t):
	if t < l:
		return v + (l - t)
	elif r < t:
		return v + (t - r)
	else:
		return v
const_list = [(0, 0, 0)]
tsum = 0
for i in range(N):
	l = tsum
	r = tsum + tlist[i]
	v = vlist[i]
	const_list.append((l, r, v))
	tsum += tlist[i]
const_list.append((tsum, tsum, 0))
answer = 0
t = 0
while t < tsum:
	s1 = s2 = 10 ** 9
	for con in const_list:
		(l, r, v) = con
		s1 = min(s1, const(l, r, v, t))
		s2 = min(s2, const(l, r, v, t + 0.5))
	answer += (s1 + s2) * 0.5 / 2
	t += 0.5
print(answer)


n = int(input())
t = [int(m) for m in input().split()]
T = sum(t)
v = [int(m) for m in input().split()]
v.append(0)
maxv = [0]
i = 0
cnt = 0
while i < n:
	cnt += 0.5
	if t[i] == cnt:
		maxv.append(min(v[i], v[i + 1]))
		i += 1
		cnt = 0
	else:
		maxv.append(v[i])
maxv[0] = 0
maxv[2 * T] = 0
for i in range(1, 2 * T + 1):
	maxv[i] = min(maxv[i], maxv[i - 1] + 0.5)
for i in range(2 * T - 1, -1, -1):
	maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)
ans = 0
for i in range(1, 2 * T + 1):
	ans += (maxv[i - 1] + maxv[i]) * 0.5 * 0.5
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):
	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())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
maxv = [0]
for (v, t) in zip(vs, ts):
	maxv[-1] = min(maxv[-1], v)
	for ti in range(t * 2):
		maxv.append(v)
T = len(maxv)
for i in range(T - 1):
	maxv[i + 1] = min(maxv[i + 1], maxv[i] + 0.5)
maxv[-1] = 0
for i in reversed(range(T - 1)):
	maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)
ans = 0.0
for i in range(T - 1):
	ans += (maxv[i] + maxv[i + 1]) * 0.25
print(ans)


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
V = [0] + V + [0]
left = [0]
right = [0]
for i in range(N):
	left.append(right[i])
	right.append(left[-1] + T[i])
left.append(right[-1])
right.append(right[-1])
INF = float('inf')
vel = [INF] * (2 * right[-1] + 1)
for t in range(2 * right[-1] + 1):
	for i in range(N + 2):
		if t / 2 < left[i]:
			vel[t] = min(vel[t], -(t / 2) + (V[i] + left[i]))
		elif left[i] <= t / 2 and t / 2 <= right[i]:
			vel[t] = min(vel[t], V[i])
		elif t / 2 > right[i]:
			vel[t] = min(vel[t], t / 2 + (V[i] - right[i]))
ans = 0
for t in range(2 * right[-1]):
	ans += 1 / 2 * 0.5 * (vel[t] + vel[t + 1])
print(ans)


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 in range(N):
	te += t[i] * 2
	for j in range(T + 1):
		vt[j] = min(vt[j], v[i] + max(0, -(j - ts) / 2, (j - te) / 2))
	ts = te
print(sum(vt) / 2)


n = int(input())
T = list(map(int, input().split()))
t = [0]
for i in range(n):
	t.append(t[-1] + T[i])
v = list(map(int, input().split()))
ans = 0
prev_spped = 0
for x in range(1, 2 * t[-1] + 1):
	time = x / 2
	speeds = [time, t[-1] - time]
	for i in range(n):
		if time <= t[i]:
			speeds.append(v[i] + t[i] - time)
		elif t[i] < time <= t[i + 1]:
			speeds.append(v[i])
		else:
			speeds.append(v[i] + time - t[i + 1])
	speed = min(speeds)
	ans += (speed + prev_spped) * 0.25
	prev_spped = speed
print(ans)


N = int(input())
(*t,) = map(int, input().split())
(*v,) = map(int, input().split())
sumt = sum(t)
sv = [0]
for i in range(N):
	for j in range(t[i] * 2):
		sv.append(v[i])
sv.append(0)
dp = [[-float('inf')] * 201 for _ in range(sumt * 2 + 1)]
dp[0][0] = 0
for i in range(1, len(dp)):
	maxj = min(sv[i], sv[i + 1]) * 2
	for j in range(len(dp[i])):
		k = 0.25 * j
		if j <= maxj:
			dp[i][j] = max(dp[i][j], dp[i - 1][j] + k)
		if j + 1 <= maxj:
			dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j] + k + 0.25)
		if j > 0 and j - 1 <= maxj:
			dp[i][j - 1] = max(dp[i][j - 1], dp[i - 1][j] + k - 0.25)
print(dp[-1][0])


n = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
s = [0] * n
for i in range(n - 1):
	s[i + 1] = s[i] + T[i]
l = (s[-1] + T[n - 1]) * 2 + 1
ans = [1e+100] * l
for i in range(l):
	ans[i] = min(ans[i], i / 2)
	ans[l - i - 1] = min(ans[i], i / 2)
for j in range(n):
	for i in range(l):
		if i <= s[j] * 2:
			ans[i] = min(ans[i], V[j] + (s[j] * 2 - i) / 2)
		elif s[j] * 2 <= i <= s[j] * 2 + T[j] * 2:
			ans[i] = min(ans[i], V[j])
		else:
			ans[i] = min(ans[i], V[j] + (i - s[j] * 2 - T[j] * 2) / 2)
anser = 0
for i in range(l - 1):
	anser += (ans[i] + ans[i + 1]) / 4
print(anser)


N = int(input())
(*T,) = map(int, input().split())
(*V,) = map(int, input().split())
speed = [0]
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)


import sys

def input():
	return sys.stdin.readline()[:-1]
N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
l = []
for i in range(N):
	l += [v[i]] * t[i]
l.append(0)
T = sum(t)
for i in range(T - 1, 0, -1):
	if l[i] < l[i + 1]:
		l[i + 1] = l[i] + 0.5
s = [100] * (T + 1)
(s[0], s[-1]) = (0, 0)
c = 1
while c:
	c = 0
	for i in range(1, T):
		if s[i] > s[i - 1] + 1:
			s[i] = s[i - 1] + 1
			c = 1
		if s[i] > s[i + 1] + 1:
			s[i] = s[i + 1] + 1
			c = 1
		if s[i] > l[i]:
			s[i] = int(l[i])
			c = 1
a = 0
for i in range(T):
	if s[i + 1] != s[i]:
		a += (s[i + 1] + s[i]) / 2
	elif s[i] < l[i]:
		a += s[i] + 0.25
	else:
		a += s[i]
print(a)


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)


import sys
input = sys.stdin.readline
N = int(input())
T0 = list(map(int, input().split()))
V = list(map(int, input().split()))
INF = 1000

def main():
	Tmax = 0
	T = [0]
	for t in T0:
		Tmax += t
		T.append(Tmax)
	preh = 0
	ans = 0
	for t0 in range(2 * Tmax + 1):
		t = t0 / 2
		height = INF
		for n in range(-1, N + 1):
			if n == -1:
				(t1, t2, v) = (-1, 0, 0)
			elif n == N:
				(t1, t2, v) = (Tmax, Tmax + 1, 0)
			else:
				(t1, t2, v) = (T[n], T[n + 1], V[n])
			if t < t1:
				y = v + t1 - t
			elif t1 <= t <= t2:
				y = v
			else:
				y = v + t - t2
			height = min(height, y)
		ans += (preh + height) * 0.5 / 2
		preh = height
	print(ans)
main()


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, 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(ans)
solve()


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()))
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())
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)


n = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
dp = [[-1] * 102 for _ in range(sum(T) + 1)]
dp[0][0] = 0
nt = 0
pt = T[0]
delta = [-1, 0, 1]
for i in range(sum(T)):
	if pt == i:
		nt += 1
		pt += T[nt]
	for j in range(101):
		if j > V[nt] or dp[i][j] == -1:
			break
		for d in delta:
			nj = j + d
			if 0 <= nj <= V[nt]:
				if d != 0 or j == V[nt]:
					dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + (j + nj) / 2)
				else:
					dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + j + 0.25)
print(dp[-1][0])


INF = 10 ** 18
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
V = [0] + V + [0]
R = [(0, 0)] * (N + 2)
for i in range(1, N + 1):
	R[i] = (R[i - 1][1], R[i - 1][1] + T[i - 1])
R[N + 1] = (R[N][1], R[N][1])

def velocity(i, x):
	if x < R[i][0]:
		return V[i] + R[i][0] - x
	elif R[i][0] <= x <= R[i][1]:
		return V[i]
	else:
		return V[i] + x - R[i][1]
ans = 0
dp = [0] * (R[N + 1][1] * 2 + 1)
for x in range(1, R[N + 1][1] * 2 + 1):
	mi = INF
	for i in range(N + 2):
		mi = min(velocity(i, x / 2), mi)
	dp[x] = mi
	ans += 0.25 * (dp[x - 1] + mi)
print(ans)


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) = 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)
main()


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 = [int(i) for i in input().split()]
L = [0]
for i in range(N):
	L.append(L[i] + T[i])
V = [int(i) for i in input().split()]

def VM(x, i):
	if 0 <= x <= L[i]:
		return V[i] + (L[i] - x)
	elif L[i] < x <= L[i + 1]:
		return V[i]
	else:
		return V[i] + (x - L[i + 1])
Search = [[] for i in range(N)]
for i in range(N):
	for j in range(N):
		if i < j and V[i] - V[j] > L[j] - L[i + 1]:
			Search[i].append(j)
		elif i > j and V[i] - V[j] > L[i] - L[j + 1]:
			Search[i].append(j)
maxV = [float('inf') for i in range(2 * L[-1] + 1)]
for i in range(N):
	for j in range(2 * L[i], 2 * L[i + 1] + 1):
		maxV[j] = min(V[i], j * 0.5, L[-1] - j * 0.5)
		for s in Search[i]:
			maxV[j] = min(maxV[j], VM(j * 0.5, s))
Ans = 0
for i in range(2 * L[-1]):
	Ans += (maxV[i] + maxV[i + 1]) / 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):
	y = heapq.heappop(v2)
	if ans[y[1]][0] == -1:
		now1 = 0
		ansi1 = inf
		for j in range(y[1] - 1, -1, -1):
			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]
	if ans[y[1]][1] == -1:
		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]
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)


n = int(input())
T = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]
M = []
for i in range(n):
	M += [V[i]] * T[i] * 2
M = [min(v1, v2) for (v1, v2) in zip([0] + M, M + [0])]
for i in range(1, len(M)):
	M[i] = min(M[i], M[i - 1] + 0.5)
for i in range(len(M) - 2, 0, -1):
	M[i] = min(M[i], M[i + 1] + 0.5)
ans = 0
for i in range(1, len(M)):
	ans += 0.5 * (M[i] + M[i - 1]) * 0.5
print(ans)


def main():
	N = int(input())
	Tn = tuple(map(int, input().split()))
	Vn = tuple(map(int, input().split()))
	t = (0,) + Tn + (0,)
	v = (0,) + Vn + (0,)
	maxv = [0]
	for i in range(1, N + 1):
		if v[i - 1] <= v[i] > v[i + 1]:
			maxv += [v[i]] * (t[i] * 2 - 1)
		elif v[i - 1] > v[i] <= v[i + 1]:
			maxv += [v[i]] * (t[i] * 2 + 1)
		else:
			maxv += [v[i]] * t[i] * 2
	maxv += [0]
	cnt = len(maxv)
	for i in range(1, cnt):
		maxv[i] = min(maxv[i], maxv[i - 1] + 0.5)
	for i in range(cnt - 2, -1, -1):
		maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)
	s = 0
	for i in range(cnt - 1):
		s += (maxv[i] + maxv[i + 1]) * 0.5 / 2
	print(s)
main()


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)


(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] + 0.5)
for i in range(2 * s, 0, -1):
	a[i - 1] = min(a[i - 1], a[i] + 0.5)
print(sum(a) / 2)


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
TMAX = sum(T)
TS = [0] * (N + 1)
for i in range(N):
	TS[i + 1] = TS[i] + T[i]
T_Left = TS[:N]
T_Right = TS[1:]
VV = [min(i * 0.5, (TMAX * 2 - i) * 0.5) for i in range(TMAX * 2 + 1)]
for i in range(N):
	for tt in range(TMAX * 2 + 1):
		VV[tt] = min(VV[tt], V[i] + max(0, (T_Left[i] * 2 - tt) * 0.5, (tt - T_Right[i] * 2) * 0.5))
print(sum(VV) / 2)


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())
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 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)
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])
answer = 0
for i in range(timelistsize - 1):
	answer += (REAL_V[i] + REAL_V[i + 1]) * 0.5 / 2
print(answer)


import sys
input = sys.stdin.readline
from collections import *
N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
end = [-1] * N
end[-1] = 0
for i in range(N - 2, -1, -1):
	end[i] = min(end[i + 1] + t[i + 1], v[i], v[i + 1])
ans = 0
s = 0
for i in range(N):
	e = end[i]
	if s + t[i] <= e:
		ans += (s + s + t[i]) * t[i] / 2
		s = s + t[i]
	else:
		up = min(v[i], (s + e + t[i]) / 2)
		ans += (s + up) * (up - s) / 2
		ans += (e + up) * (up - e) / 2
		ans += up * (t[i] - (up - s) - (up - e))
		s = e
print(ans)


n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
ans = 0
bound = [0] * (n + 1)
for i in range(n - 1):
	bound[i + 1] = min(v[i], v[i + 1], bound[i] + t[i])
for i in range(n - 1, 0, -1):
	bound[i] = min(bound[i], v[i], v[i - 1], bound[i + 1] + t[i])
ans = 0
for i in range(n):
	l = bound[i]
	r = bound[i + 1]
	x = (r - l + t[i]) / 2
	if l + x <= v[i]:
		ans += (l + (l + x)) * x / 2 + (l + x + r) * (t[i] - x) / 2
	else:
		ans += (v[i] + l) * (v[i] - l) / 2 + (v[i] + r) * (v[i] - r) / 2
		ans += (t[i] - (v[i] - l) - (v[i] - r)) * v[i]
print('{:.14f}'.format(ans))


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
Tsum = sum(T)
keika = []
tmp = 0
for i in range(N):
	keika.append([tmp, tmp + T[i]])
	tmp += T[i]
G = [[0] * (N + 1) for i in range(2 * Tsum + 1)]
for i in range(2 * Tsum + 1):
	G[i][0] = min(i / 2, Tsum - i / 2)
for i in range(N):
	(t0, t1) = keika[i]
	for j in range(2 * t0):
		G[j][i + 1] = V[i] + t0 - j / 2
	for j in range(2 * t0, 2 * t1 + 1):
		G[j][i + 1] = V[i]
	for j in range(2 * t1 + 1, 2 * Tsum + 1):
		G[j][i + 1] = V[i] + j / 2 - t1
ans = 0
for i in range(2 * Tsum):
	v0 = min(G[i])
	v1 = min(G[i + 1])
	ans += (v0 + v1) / 4
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)


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]
	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
	yy = [0] * (n + 1)
	for i in range(n - 1):
		yy[i + 1] = min(max_vL[i], max_vR[i])
	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 = [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):
	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()))
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(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)


import sys, queue, math, copy, itertools, bisect, collections, heapq

def main():
	sys.setrecursionlimit(10 ** 7)
	INF = 10 ** 18
	MOD = 10 ** 9 + 7
	LI = lambda : [int(x) for x in sys.stdin.readline().split()]
	NI = lambda : int(sys.stdin.readline())
	SI = lambda : sys.stdin.readline().rstrip()
	N = NI()
	t = LI()
	v = LI() + [0]
	p = [0] * (N + 1)
	for i in range(N):
		p[i + 1] = min(p[i] + t[i], v[i], v[i + 1])
		j = i
		while p[j] > p[j + 1] + t[j] and j > 0:
			p[j] = min(v[j], p[j + 1] + t[j])
			j -= 1
	ans = 0
	for i in range(N):
		s1 = v[i] - p[i]
		s2 = v[i] - p[i + 1]
		ans += v[i] * t[i] - s1 * s1 / 2 - s2 * s2 / 2
		if s1 + s2 > t[i]:
			ans += (s1 + s2 - t[i]) ** 2 / 4
	print(ans)
main()


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]
	elif 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 = list(map(int, input().split()))
v = list(map(int, input().split()))
e = sum(t) * 2
vmax = [0 for k in range(e + 2)]
s = 0
for k in range(N):
	for l in range(1, t[k] * 2 + 1):
		vmax[s + l] = v[k]
	s += t[k] * 2
hidari = [0 for k in range(e + 1)]
for k in range(1, e + 1):
	hidari[k] = min(hidari[k - 1] + 0.5, vmax[k])
migi = [0 for k in range(e + 1)]
for k in range(1, e + 1):
	migi[e - k] = min(migi[e - k + 1] + 0.5, vmax[e - k + 1])
ans = 0
for k in range(e + 1):
	ans += min(hidari[k], migi[k])
print(ans / 2)


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[0][0] = 0
for i in range(1, sum_t[-1] + 1):
	bef = bisect_left(sum_t, i - 1)
	phase = bisect_left(sum_t, i)
	bef_bound = vel[bef - 1]
	bound = vel[phase - 1]
	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)
				elif 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)
				elif j == bef_bound:
					dp[i][j] = max(dp[i - 1][j - 1] + j - 0.5, dp[i - 1][j] + j + 0.25)
				elif 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:
				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)


n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
v.insert(0, 0)
v.append(0)
l = [0, 0]
r = [0]
for i in range(n):
	l.append(l[i + 1] + t[i])
	r.append(l[i + 2])
r.append(r[n])
d = 0
vl = 0
for k in range(l[n + 1] * 2):
	now = k / 2 + 0.5
	vr = 1000
	for i in range(n + 2):
		tv = 0
		if now < l[i]:
			tv = v[i] + l[i] - now
		elif now < r[i]:
			tv = v[i]
		else:
			tv = v[i] + now - r[i]
		vr = min(vr, tv)
	d += (vl + vr) * 0.25
	vl = vr
print(d)


import sys
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()
YesNo = lambda b: bool([print('Yes')] if b else print('No'))
YESNO = lambda b: bool([print('YES')] if b else print('NO'))
int1 = lambda x: int(x) - 1
N = int(input())
T = [0] + list(map(lambda x: int(x) * 2, input().split())) + [0]
V = [0] + list(map(lambda x: int(x) * 2, input().split())) + [0]
v = [INF] * (sum(T) + 1)

def f(v, l, r, t):
	if t < l:
		return v + (l - t)
	elif l <= t < r:
		return v
	else:
		return v + (t - r)
t = 0
for i in range(N + 2):
	for j in range(len(v)):
		v[j] = min(v[j], f(V[i], t, t + T[i], j))
	t += T[i]
ans = 0
for i in range(len(v) - 1):
	ans += v[i] + v[i + 1]
ans /= 8
print(ans)


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
S = sum(T)
v = [0] * (sum(T) * 2 + 1)

def f(x, l, r, vmax):
	if x < l:
		return vmax + (l - x)
	elif l <= x <= r:
		return vmax
	else:
		return vmax + (x - r)
for i in range(S * 2 + 1):
	l = 0
	r = 0
	v[i] = f(i * 0.5, l, r, 0)
	for j in range(N):
		r += T[j]
		v[i] = min(v[i], f(i * 0.5, l, r, V[j]))
		l = r
	v[i] = min(v[i], f(i * 0.5, l, r, 0))
ans = 0
for i in range(S * 2):
	ans += (v[i + 1] + v[i]) * 0.25
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)


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
l = sum(T) * 2 + 1
t_cond = [0] + T + [0]
v_cond = [0] + V + [0]
memo = [[0] * l for _ in range(N + 2)]
left = 0
for i in range(N + 2):
	for j in range(l):
		if j < left:
			memo[i][j] = v_cond[i] + (left - j) * 0.5
		elif left <= j <= left + t_cond[i] * 2:
			memo[i][j] = v_cond[i]
		else:
			memo[i][j] = v_cond[i] + (j - left - t_cond[i] * 2) * 0.5
	left += t_cond[i] * 2
f = [min((memo[i][j] for i in range(N + 2))) for j in range(l)]
ans = 0
for i in range(l - 1):
	ans += 0.25 * (f[i] + f[i + 1])
print(ans)


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)]
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))


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)


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_left = deque([0])
	v_right = deque([0])
	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)]
	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
	if vmax > vsup:
		(a, b) = (vsup - vin, t + vout - vsup)
		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

def __starting_point():
	main()
__starting_point()


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())
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
for i in range(n):
	max_v[i] = min(i / 2, sum_t - i / 2)
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
ans = sum(max_v) - (max_v[0] + max_v[-1]) / 2
print(ans / 2)


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
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
	from itertools import accumulate
	dh = 10
	n = int(readline())
	t_ = [0] + list(map(int, readline().split()))
	t_list = list(accumulate(t_))
	v_list = list(map(int, readline().split())) + [0]
	lim = [0] * (sum(t_list) * dh + 1)
	for i in range(n):
		st = dh * t_list[i]
		nt = dh * t_list[i + 1]
		cv = v_list[i]
		pv = lim[st]
		nv = v_list[i + 1]
		for ct in range(st, nt + 1):
			lim[ct] = min(cv, pv + (ct - st) / dh)
	for i in range(1, n + 1):
		st = dh * t_list[i]
		sv = v_list[i]
		for ct in range(st, -1, -1):
			lim[ct] = min(lim[ct], sv + (st - ct) / dh)
	ans = 0
	pv = 0
	for v in lim[1:]:
		ans += (pv + (v - pv) / 2) / dh
		pv = v
	print(ans)
main()


N = int(input())
T = list(map(int, input().split()))
V = [0] + list(map(int, input().split())) + [0]
Tc = [0, 0] + [sum(T[:i + 1]) for i in range(N)] + [sum(T)]
ans = 0
for i in range(sum(T) * 2):
	(t1, t2) = (i * 0.5, (i + 1) * 0.5)
	(maxV1, maxV2) = ([], [])
	for j in range(N + 2):
		for (t, maxV) in [(t1, maxV1), (t2, maxV2)]:
			if t <= Tc[j]:
				maxV.append(V[j] + (Tc[j] - t))
			elif Tc[j] < t <= Tc[j + 1]:
				maxV.append(V[j])
			else:
				maxV.append(V[j] + (t - Tc[j + 1]))
	ans += 0.25 * (min(maxV1) + min(maxV2))
print(ans)


N = int(input())
T = [int(x) for x in input().split()]
V = [int(x) for x in input().split()]
T.append(0)
V.append(0)
Vt = [0 for i in range(N + 1)]
r = sum(T)
R = [0 for i in range(N)]
for i in range(N - 1):
	r -= T[i]
	R[i] = r
for i in range(N - 1, -1, -1):
	Vt[i] = min(V[i], V[i + 1], Vt[i + 1] + T[i + 1])
L = 0
v0 = 0
for i in range(N):
	ta = min(V[i] - v0, (T[i] - (v0 - Vt[i])) / 2, T[i])
	tb = max(v0 + ta - Vt[i], 0)
	L += (2 * v0 + ta) * ta / 2 + (v0 + ta) * (T[i] - ta - tb) + (2 * (v0 + ta) - tb) * tb / 2
	v0 = v0 + ta - tb
print(L)


INF = 10 ** 20
n = int(input())
tlst = list(map(int, input().split()))
vlst = list(map(int, input().split()))
dp = [[-INF] * 201 for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
	(t, v) = (tlst[i], vlst[i])
	for v_fr in range(v + 1):
		pre_score = dp[i][v_fr]
		for v_to in range(v + 1):
			diff = abs(v_to - v_fr)
			if diff > t:
				continue
			max_speed = min((v_to + v_fr + t) / 2, v)
			dp[i + 1][v_to] = max(dp[i + 1][v_to], pre_score + max_speed * t - (max_speed - v_to) ** 2 / 2 - (max_speed - v_fr) ** 2 / 2)
print(dp[n][0])


import sys

def main():
	LI = lambda : [int(x) for x in sys.stdin.readline().split()]
	NI = lambda : int(sys.stdin.readline())
	N = NI()
	t = LI()
	v = LI() + [0]
	p = [0] * (N + 1)
	for i in range(N):
		p[i + 1] = min(p[i] + t[i], v[i], v[i + 1])
		j = i
		while p[j] > p[j + 1] + t[j] and j > 0:
			p[j] = p[j + 1] + t[j]
			j -= 1
	ans = 0
	for i in range(N):
		s1 = v[i] - p[i]
		s2 = v[i] - p[i + 1]
		ans += v[i] * t[i] - s1 * s1 / 2 - s2 * s2 / 2
		if s1 + s2 > t[i]:
			ans += (s1 + s2 - t[i]) ** 2 / 4
	print(ans)
main()


from itertools import accumulate
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
clock = [0] + list(accumulate(T))
t_sum = sum(T)
mn_f = 0
ans = 0
for t in range(2 * t_sum):
	t /= 2
	mn = min(t, t_sum - t)
	for i in range(1, len(clock)):
		v = V[i - 1]
		if t < clock[i - 1]:
			v_max = v + clock[i - 1] - t
		elif clock[i - 1] <= t <= clock[i]:
			v_max = v
		else:
			v_max = v + t - clock[i]
		mn = min(mn, v_max)
	ans += (mn_f + mn) * 0.25
	mn_f = mn
ans += mn_f * 0.25
print(ans)


N = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
sumT = sum(ts)
va = [min(i / 2, sumT - i / 2) for i in range(2 * sumT + 1)]
accT = 0
for (t, v) in zip(ts, vs):
	for i in range(accT, accT + 2 * t + 1):
		va[i] = min(va[i], v)
	accT += t * 2
for i in range(len(va) - 1):
	if va[i + 1] - va[i] > 0.5:
		va[i + 1] = va[i] + 0.5
for i in range(len(va) - 1)[::-1]:
	if va[i] - va[i + 1] > 0.5:
		va[i] = va[i + 1] + 0.5
print(sum(va) / 2)


N = int(input())
T = list(map(lambda x: int(x) * 2, input().split()))
V = list(map(lambda x: int(x) * 2, input().split())) + [0]
sumt = sum(T)
maxv = [min(i, sumt - i) for i in range(sumt + 1)]
ct = 0
for (t, v) in zip(T, V):
	for i in range(ct, ct + t + 1):
		maxv[i] = min(maxv[i], v)
	ct += 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(float(sum(maxv)) / 4)


from itertools import accumulate as ac
o = []
f = lambda l, r, v: lambda x: v if l <= x <= r else v + (l - x) if 0 <= x <= l else v + (x - r)
o.extend([f(0, 0, 0)])
n = int(input())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
(*c,) = ac([0] + a)
for (i, (t, v)) in enumerate(zip(a, b)):
	o.extend([f(c[i], c[i + 1], v)])
o.extend([f(c[-1], c[-1], 0)])
v = lambda s: min(map(lambda x: x(0.5 * s), o))
S = 0
for i in range(2 * c[-1]):
	S += 0.25 * (v(i) + v(i + 1))
print(S)


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(lambda x: int(x), input().split()))
V = list(map(lambda x: int(x), input().split()))
dp = [[-float('inf')] * 101 for _ in range(N + 1)]
V.append(0)
dp[0][0] = 1
for i in range(N):
	for v in range(V[i] + 1):
		for vv in range(V[i] + 1):
			past_dist = dp[i][v]
			if 2 * V[i] - v - vv <= T[i]:
				a = V[i] - v
				b = V[i] - vv
				c = (v + V[i]) * a / 2 + V[i] * (T[i] - a - b) + (vv + V[i]) * b / 2
				dp[i + 1][vv] = max(dp[i + 1][vv], c + past_dist)
			elif T[i] >= abs(vv - v):
				ta = (vv - v + T[i]) / 2
				tb = (T[i] + v - vv) / 2
				c = (2 * v + ta) * ta / 2 + (vv + v + ta) * tb / 2
				dp[i + 1][vv] = max(dp[i + 1][vv], c + past_dist)
print(dp[N][0] - 1)


from pprint import pprint
N = int(input())
tn = list(map(int, input().split()))
vn = list(map(int, input().split()))
tn_sum = sum(tn)
time_tbl = [0 for _ in range(tn_sum * 2 + 1)]
lrv = []
lrv.append([0, 0, 0])
t_sum = 0
for (t, v) in zip(tn, vn):
	lrv.append([t_sum, t_sum + t, v])
	t_sum += t
lrv.append([tn_sum, tn_sum, 0])

def f(l, r, x, v):
	if x <= l:
		return v + l - x
	elif l < x < r:
		return v
	else:
		return v + x - r
for t05 in range(tn_sum * 2 + 1):
	time_tbl[t05] = min([f(l, r, t05 / 2, v) for (l, r, v) in lrv])
area = 0.0
for i in range(tn_sum * 2):
	area += (time_tbl[i] + time_tbl[i + 1]) / 4
print(area)


n = int(input())
time = list(map(int, input().split()))
speed = list(map(int, input().split()))
speed = [0] + speed + [0]
cumtime = [0] * (n + 1)
for i in range(n):
	cumtime[i + 1] = cumtime[i] + time[i]
dis = 0.0
prev = 0
l = cumtime[n]
tp = 1
for t in range(1, l + 1):
	if t > cumtime[tp]:
		tp += 1
	v = speed[tp]
	v = min(v, prev + 1)
	for i in range(tp):
		v = min(v, t - cumtime[i] + speed[i])
	for i in range(tp + 1, n + 2):
		v = min(v, cumtime[i - 1] - t + speed[i])
	if v == prev and v < speed[tp]:
		dis += v + 1 / 4
	else:
		dis += (v + prev) / 2
	prev = v
print(dis)


N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
st = [0]
s = 0
for i in range(N):
	s += t[i]
	st.append(s)
T = st[N]
i = 0
max_v = [0]
while i <= T:
	mv = 10 ** 28
	for j in range(N):
		if i < st[j]:
			mv = min(v[j] + st[j] - i, mv)
		elif i > st[j + 1]:
			mv = min(v[j] + i - st[j + 1], mv)
		else:
			mv = min(v[j], mv)
	mv = min(T - i, i, mv)
	max_v.append(mv)
	i += 0.5
ans = 0
for i in range(len(max_v) - 1):
	ans += (max_v[i] + max_v[i + 1]) / 4
print(ans)


import sys
from itertools import accumulate

def main():
	input = sys.stdin.readline
	N = int(input())
	T = list(map(int, input().split()))
	V_limit = list(map(int, input().split()))
	V = []
	for i in range(N):
		V += [V_limit[i] for _ in range(2 * T[i])]
	for i in range(len(V) - 1):
		V[i] = min(V[i], V[i + 1])
	V = [0] + V
	V[-1] = 0
	for i in range(len(V) - 1):
		V[i + 1] = min(V[i] + 0.5, V[i + 1])
	for i in range(len(V) - 1, 0, -1):
		V[i - 1] = min(V[i] + 0.5, V[i - 1])
	ans = 0
	for i in range(len(V) - 1):
		ans += 0.25 * (V[i] + V[i + 1])
	print(ans)
main()


from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
import functools

def read():
	return int(input())

def reads():
	return [int(x) for x in input().split()]
N = read()
t = reads()
v = reads()
psumt = [0] + list(accumulate(t))
T = psumt[-1]
vs = [0] * (T + 1)
ans = 0
for ss in range(0, 2 * T):
	s = ss / 2
	m = min(abs(s), min((v[i] + (abs(psumt[i] - s) + abs(psumt[i + 1] - s) - t[i]) / 2 for i in range(N))), abs(T - s))
	ans += m / 2
print('%.9f' % ans)


v = 0
t = 0
n = int(input())
T = [0] + list(map(int, input().split())) + [0]
V = [0] + list(map(int, input().split())) + [0]
cumT = [0] * (len(T) + 1)
for i in range(len(T)):
	cumT[i + 1] = cumT[i] + T[i]
imos = [1000] * (sum(T) + 1)
for i in range(len(T)):
	for j in range(T[i]):
		imos[cumT[i] + j] = V[i]
horizon = imos.copy()
for i in range(len(T)):
	for j in range(len(imos) - cumT[i + 1]):
		imos[cumT[i + 1] + j] = min([imos[cumT[i + 1] + j], V[i] + j])
	for j in range(cumT[i + 1]):
		imos[cumT[i] - j] = min([imos[cumT[i] - j], V[i] + j])
ret = 0.0
for i in range(len(imos) - 1):
	ret += (imos[i] + imos[i + 1] + 0.5 if imos[i] == imos[i + 1] and imos[i] < horizon[i] else imos[i] + imos[i + 1]) / 2
print(ret)


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()
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
		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
		if spd + 1 - dist > B[j]:
			return False
	return True
cur = spd = sm = 0
for (i, a) in enumerate(A[:N]):
	b = B[i]
	for t in range(cur, cur + a):
		if spd + 1 <= b and check1(i, t):
			sm += spd + 0.5
			spd += 1
		elif spd <= b and check2(i, t):
			sm += spd
		else:
			sm += spd - 0.5
			spd -= 1
	cur += a
print(sm / 4)


N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
T0 = sum(T)
INF = float('inf')
M = 2 * T0 + 1
(l, r) = (0, 0)
maxv = [INF] * M
for i in range(N):
	l = r
	r += T[i]
	for k in range(2 * l, 2 * r + 1):
		maxv[k] = min(maxv[k], V[i])
maxv[0] = 0
maxv[M - 1] = 0
for i in range(1, M):
	maxv[i] = min(maxv[i], maxv[i - 1] + 0.5)
for i in range(M - 2, -1, -1):
	maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)
ans = 0
for i in range(1, M):
	ans += 0.25 * (maxv[i] + maxv[i - 1])
print(ans)


n = int(input())
t = list(map(int, input().split()))
runt = sum(t)
t.append(0)
for i in range(n):
	t[i + 1] += t[i]
v = list(map(int, input().split()))
v.append(0)
det = [v[i] + t[i - 1] for i in range(1, n + 1)]
runlen = 0.0
vnow = 0.0
idx = 0
for se in range(2 * runt):
	now = se / 2
	if t[idx] == now:
		idx += 1
	lim = min(det[idx:])
	if -lim + now + vnow == 0.0:
		vnow -= 0.5
		runlen += vnow * 0.5 + 0.25
	elif v[idx] == vnow:
		runlen += vnow * 0.5
	else:
		vnow += 0.5
		runlen += vnow * 0.5 - 0.25
print(runlen)


def f(x, l, r, v):
	if 0 <= x <= l:
		return v + (l - x)
	if l <= x <= r:
		return v
	if r <= x:
		return v + x - r

def speed(t):
	num = 10 ** 9
	for (l, r, v) in table:
		num = min(num, f(t, l, r, v))
	return num
N = int(input())
T = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]
X = [0] * (N + 1)
for i in range(1, N + 1):
	X[i] = X[i - 1] + T[i - 1]
table = [(X[i], X[i + 1], V[i]) for i in range(N)]
table.append((0, 0, 0))
table.append((X[-1], X[-1], 0))
s = speed(0)
meter = 0
for i in range(1, 2 * X[-1] + 1):
	t = speed(i * 0.5)
	meter += (s + t) * 0.25
	s = t
print(meter)


N = int(input())
T = [int(_) for _ in input().split()]
for i in range(N - 1):
	T[i + 1] += T[i]
T = [0] + T
V = [int(_) for _ in input().split()]
V = V
vel = [min(i / 2, T[-1] - i / 2) for i in range(2 * T[-1] + 1)]
for i in range(N):
	for j in range(2 * T[-1] + 1):
		vel[j] = min(vel[j], max(V[i], -j / 2 + T[i] + V[i], j / 2 - T[i + 1] + V[i]))
print((2 * sum(vel) - vel[0] - vel[-1]) / 4)


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)


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
	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)
	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()


import sys
stdin = sys.stdin
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
ns = lambda : stdin.readline()
n = ni()
t = na()
v = na()
bound = [0] * (n + 1)
for i in range(n - 1):
	bound[i + 1] = min(v[i], v[i + 1], bound[i] + t[i])
for i in range(n - 1, 0, -1):
	bound[i] = min(bound[i], v[i], v[i - 1], bound[i + 1] + t[i])
ans = 0
for i in range(n):
	l = bound[i]
	r = bound[i + 1]
	x = (r - l + t[i]) / 2
	if l + x <= v[i]:
		ans += (l + (l + x)) * x / 2 + (l + x + r) * (t[i] - x) / 2
	else:
		ans += (v[i] + l) * (v[i] - l) / 2 + (v[i] + r) * (v[i] - r) / 2
		ans += (t[i] - (v[i] - l) - (v[i] - r)) * v[i]
print('{:.14f}'.format(ans))


from itertools import accumulate
import bisect
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
t = [0] + t
t = list(accumulate(t))
v.append(0)
for i in range(1, len(t)):
	v[-i - 1] = min(v[-i] + t[-i] - t[-i - 1], v[-i - 1])
a = [0]
for i in range(1, t[-1] * 2 + 1):
	j = i / 2
	b = bisect.bisect_left(t, j)
	a.append(min(a[-1] + 1 / 2, v[b - 1], v[b] + t[b] - j))
print(sum(a) / 2)


N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
tl = []
v1 = [0] + v + [0]
ts = 0
for i in range(N + 1):
	tl.append([ts, min(v1[i], v1[i + 1])])
	if i != N:
		ts += t[i]
max_v = []
k = 0
for i in range(2 * ts + 1):
	mv = 10 ** 27
	if tl[k + 1][0] < i / 2:
		k += 1
	for j in range(len(tl)):
		mv = min(mv, abs(i / 2 - tl[j][0]) + tl[j][1], v[k])
	max_v.append(mv)
s = 0
for i in range(2 * ts):
	s += max_v[i] + max_v[i + 1]
print(s / 4)


N = int(input())
T = [0] + [int(x) for x in str(input()).split()] + [0]
V = [0] + [int(x) for x in str(input()).split()] + [0]
time = 0
t = [0]
for i in T:
	time += i
	t.append(time)
ans = 0
for j in range(0, 2 * time):
	m1 = 1000000000
	m2 = 1000000000
	t1 = j / 2
	t2 = (j + 1) / 2
	for i in range(N + 2):
		if t1 <= t[i]:
			m1 = min(m1, V[i] + (t[i] - t1))
		elif t1 <= t[i + 1]:
			m1 = min(m1, V[i])
		else:
			m1 = min(m1, V[i] + t1 - t[i + 1])
		if t2 <= t[i]:
			m2 = min(m2, V[i] + (t[i] - t2))
		elif t2 <= t[i + 1]:
			m2 = min(m2, V[i])
		else:
			m2 = min(m2, V[i] + t2 - t[i + 1])
	ans += 0.25 * (m1 + m2)
print(ans)


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
	elif 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())
tt = map(int, input().split())
vv = map(int, input().split())
v_now = 0
v_max = [v_now]
for (t, v) in reversed(list(zip(tt, vv))):
	for i in range(t * 2):
		if v_now + 0.5 <= v:
			v_now += 0.5
		else:
			v_now = min(v_now, v)
		v_max.append(v_now)
v_max = v_max[::-1]
v = 0
total = 0
for i in range(len(v_max) - 1):
	v0 = v_max[i]
	v1 = v_max[i + 1]
	if v + 0.5 <= v1:
		if v < v0:
			total += (v + v + 0.5) * 0.25
			v += 0.5
		else:
			total += v * 0.5
	elif v > v1:
		total += (v + v - 0.5) * 0.25
		v -= 0.5
		assert v == v1, '%s %s' % (v, v1)
	else:
		total += v * 0.5
print(total)


n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split())) + [0]
V = max(v)
dp = [[0]] + [[] for i in range(V)]
for i in range(0, n):
	a = t[i]
	b = v[i]
	c = v[i + 1]
	h = [[] for j in range(V + 1)]
	for j in range(V + 1):
		l = V - j
		if dp[l]:
			if max(0, l - a) <= min(b, l + a):
				for k in range(max(0, l - a), min(b, c, l + a) + 1):
					if not h[k]:
						h[k] = dp[l] + [k]
	dp = h
ans = 0
for i in range(n):
	a = t[i]
	b = v[i]
	v1 = dp[0][i]
	v2 = dp[0][i + 1]
	if v1 == v2 == b:
		ans += a * b
	elif v1 == b:
		ans += a * b - (b - v2) ** 2 / 2
	elif v2 == b:
		ans += a * b - (b - v1) ** 2 / 2
	elif 2 * b - v1 - v2 <= a:
		ans += a * b - (b - v2) ** 2 / 2 - (b - v1) ** 2 / 2
	else:
		ans += a * a / 2 + a * v1 - (a + v1 - v2) ** 2 / 4
print(ans)


from itertools import chain
double = lambda c: int(c) * 2
N = int(input())
T = tuple(map(double, input().split()))
V = tuple(map(double, input().split()))
dp = [0]
for (t, v_max, vf_max) in zip(T, V, chain(V[1:], (0,))):
	ndp = [None] * (min(vf_max, v_max) + 1)
	for vf in range(len(ndp)):
		vi = min(len(dp) - 1, vf + t)
		while vi >= 0 and dp[vi] is None:
			vi -= 1
		if vi < max(0, vf - t):
			ndp[vf] = None
		else:
			vp = (vf + t + vi) / 2
			ndp[vf] = dp[vi] + 2 * vp * vp - vf * vf - vi * vi - 2 * max(0, vp - v_max) ** 2
	dp = ndp
print(dp[0] / 8)


import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10 ** 9 + 7
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
st = sum(t)
maxv = [0]
for i in range(n):
	maxv[-1] = min(maxv[-1], v[i])
	for _ in range(2 * t[i]):
		maxv.append(v[i])
maxv[-1] = 0
for i in range(1, 2 * st + 1):
	maxv[i] = min(maxv[i], maxv[i - 1] + 0.5)
for i in range(2 * st)[::-1]:
	maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)
ans = 0
for i in range(2 * st):
	ans += (maxv[i] + maxv[i + 1]) * 0.5 / 2
print(ans)