#include #include #include using namespace std; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) #define mp make_pair int N, A[1501], B[1501]; int solve(){ priority_queue > q0; REP(i,N) q0.push(mp(-A[i],0)); int minv = 1<<29; REP(i,N){ auto q = q0; REP(j,N){ int add = B[(i+j)%N]/2; auto a = q.top(); q.pop(); a.first-=add; a.second--; q.push(a); } int maxv = 0; while(q.size()){ maxv = max(maxv, -q.top().second); q.pop(); } minv = min(minv, maxv); } return minv; } int naive(){ vector > v0,v; REP(i,N) v0.push_back(mp(A[i],0)); sort(v0.begin(), v0.end()); int minv = 1<<29; REP(i,N){ v = v0; REP(j,N){ int add = B[(i+j)%N]/2; v[0].first += add; v[0].second++; sort(v.begin(), v.end()); } int maxv = 0; REP(j,N) maxv = max(maxv, v[j].second); //REP(j,N) cerr<<"("<> N; if(N > 1500){ cerr << "error" << endl; return 1; } REP(i,N){ cin >> A[i]; if(A[i] > 10000){ cerr << "error" << endl; return 1; } } REP(i,N){ cin >> B[i]; if(B[i] > 10000){ cerr << "error" << endl; return 1; } } cout << solve() << endl; // cout << naive() << endl; return 0; }