#include #define int long long #define REP(i, b) for(int i = 0; i < (b); i++) #define REPS(i, b) for(int i = 1; i <= (b); i++) #define ALL(v) (v).begin(), (v).end() #define fi first #define se second #define pb push_back #define mp make_pair using namespace std; using pi = pair; using vi = vector; using vs = vector; using vb = vector; using vpi = vector; using vvi = vector; using vvb = vector; const int INF = 1e16; const int MOD = 1e9+7; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); int N; cin >> N; vi A(N), B(N); REP(i, N) cin >> A[i]; REP(i, N) cin >> B[i], B[i] /= 2; int ans = INF; REP(i, N) { priority_queue> q; REP(j, N) q.push(mp(A[j], 0)); REP(j, N) { pi p = q.top(); q.pop(); p.fi += B[(i+j)%N]; p.se++; q.push(p); } int t = 0; while(!q.empty()) { pi p = q.top(); q.pop(); chmax(t, p.se); } chmin(ans, t); } cout << ans << endl; }