#include #define rep(i, a) for (int i = 0; i < (a); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define repr(i, a) for (int i = (a) - 1; i >= 0; i--) #define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--) using namespace std; typedef long long ll; const ll inf = 1e9; const ll mod = 1e9 + 7; typedef pair P; // level, times typedef priority_queue, greater

> pqueue; int N, A[1500], B[1500]; int calc(pqueue q, int s) { rep (i, N) { P p = q.top(); q.pop(); q.emplace(p.first + B[(i + s) % N] / 2, p.second + 1); } int res = 0; while (!q.empty()) { P p = q.top(); q.pop(); res = max(res, p.second); } return res; } int main() { cin >> N; rep (i, N) cin >> A[i]; rep (i, N) cin >> B[i]; pqueue q; rep (i, N) q.emplace(A[i], 0); int ans = inf; rep (i, N) { ans = min(ans, calc(q, i)); } cout << ans << endl; return 0; }