#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef unsigned long long ull; typedef long long ll; typedef pair pii; typedef pair pll; typedef pair P; const ll INF = 1ll<<29; const ll MOD = 1000000007; const double EPS = 1e-10; int n; int a[1500], b[1500]; int main() { cin >> n; REP(i, n) scanf("%d", a + i); REP(i, n) scanf("%d", b + i); int ans = INF; REP(i, n) { priority_queue, greater > pq; REP(j, n) pq.push(pll(a[j], 0)); int ma = 0; REP(j, n) { pll now = pq.top(); pq.pop(); now.first += b[(i + j) % n] / 2; now.second++; pq.push(now); chmax(ma, now.second); } chmin(ans, ma); } cout << ans << endl; return 0; }