#include #include using namespace std; #define N_MAX 1500 struct State { int level, turn; State(int l) : level(l), turn(0) {} bool operator < (const State& r) const { if (level != r.level) return level > r.level; return turn > r.turn; } }; int N; int A[N_MAX], B[N_MAX]; int main() { scanf("%d", &N); for (int i = 0; i < N; i++) scanf("%d", A + i); for (int i = 0; i < N; i++) scanf("%d", B + i); int res = 0; priority_queue pq; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) pq.emplace(A[j]); int j = i, cnt = 0; while (cnt != N) { State s = pq.top(); pq.pop(); s.level += B[j] / 2; s.turn++; pq.push(s); j = (j + 1) % N; cnt++; } while (!pq.empty()) { res = max(res, pq.top().turn); pq.pop(); } } printf("%d\n", res); return 0; }