import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random; import std.string, std.conv, std.stdio, std.typecons; struct monster { long level; long count; int opCmp(monster rhs) { int sign(long n) { return n == 0 ? 0 : (n > 0 ? 1 : -1); } auto s1 = sign(level - rhs.level); auto s2 = sign(count - rhs.count); return s1 == 0 ? s2 : s1; } } void main() { auto n = readln.chomp.to!int; auto ai = readln.split.map!(to!long).array; auto bi = readln.split.map!(to!long).array; auto m = long.max; foreach (ci; iota(n).map!(i => bi[i..$] ~ bi[0..i])) m = min(m, calcCount(ai, ci)); writeln(m); } long calcCount(long[] ai, long[] bi) { auto mi = ai.map!(a => monster(a, 0)).array; auto hi = mi.heapify!("a > b"); auto r = 0L; foreach (b; bi) { auto h = hi.front; hi.replaceFront(monster(h.level + b / 2, h.count + 1)); r = max(r, h.count + 1); } return r; }