#define REP(i,n) for(int i=0; i<(int)(n); i++) #include #include inline int getInt(){ int s; scanf("%d", &s); return s; } #include using namespace std; int main(){ const int n = getInt(); vector a(n); vector b(n); REP(i,n) a[i] = getInt(); REP(i,n) b[i] = getInt(); int ans = n; REP(s,n){ typedef pair data; priority_queue, greater > pq; REP(i,n) pq.push(make_pair(a[i], 0)); REP(i,n){ const data d = pq.top(); pq.pop(); const int bb = b[(i + s) % n]; pq.push(data(d.first + bb / 2, d.second + 1)); } int tmp = 0; while(pq.size()){ tmp = max(tmp, pq.top().second); pq.pop(); } ans = min(ans, tmp); } printf("%d\n", ans); return 0; }