#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,n) for(int i = 0; n > i; i++) using namespace std; typedef vector Ivec; typedef pair pii; int main() { int n; scanf("%d", &n); priority_queue, greater> a; vector b(n); REP(i, n) { int x; scanf("%d", &x); a.push({ x,0 }); } REP(i, n) scanf("%d", &b[i]); int ans = 1501; REP(i, n) { priority_queue, greater> party = a; int Max = 0; for(int j = 0; n > j; j++) { int num = (i + j)%n; pii cur = party.top(); cur = { cur.first + (b[num] / 2), cur.second + 1 }; Max = max(Max, cur.second); party.pop(); party.push(cur); } ans = min(ans, Max); } printf("%d\n", ans); return 0; }