#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)<>N; rep(i,N)cin>>A[i]; rep(i,N){ cin>>B[i]; B[i] /= 2; }; int ans = N; int tMaxCount=0; // priority_queue< pair, vector< pair >, greater< pair > > poke,temp; for(int m=0;m( A[m],0 ) ); } for(int i=0;i top = poke.top(); poke.pop(); poke.push( pair( top.first + B[(i+k)%N], top.second + 1 ) ); if( top.second + 1 > tMaxCount ){ tMaxCount = top.second + 1; if( ans <= tMaxCount ){ break; } } } if(ans > tMaxCount){ ans = tMaxCount; } } P(ans); return 0; }