#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int a[1500], b[1500]; typedef pair P; const int inf = 1e9; int main(void){ int N; cin >> N; for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = 0; i < N; i++) { cin >> b[i]; b[i] >>= 1; } int res = inf; for (int i = 0; i < N; i++) { int maxim = 0; priority_queue< P ,vector

,greater

> que; for (int j = 0; j < N; j++) { que.push(make_pair(a[j], 0)); } for (int j = 0; j < N; j++){ int now = i + j; now = (now < N) ? now : now - N; auto p = que.top(); que.pop(); //printf("(%d,%d)-%d\n", p.first, p.second,b[now]); p.first += b[now]; p.second++; maxim = max(maxim, p.second); que.push(p); } res = min(res, maxim); } cout << res << endl; return 0; }