#include #include #include #include #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define li long long int #define rep(i,to) for(li i=0;i<((li)(to));i++) #define repp(i,start,to) for(li i=(li)(start);i<((li)(to));i++) #define pb push_back #define sz(v) ((li)(v).size()) #define bgn(v) ((v).begin()) #define eend(v) ((v).end()) #define allof(v) (v).begin(), (v).end() #define dodp(v,n) memset(v,(li)n,sizeof(v)) #define bit(n) (1ll<<(li)(n)) #define mp(a,b) make_pair(a,b) #define rin rep(i,n) #define EPS 1e-10 #define ETOL 1e-8 #define MOD 1000000007 #define F first #define S second #define p2(a,b) cout< PI; li a[1515], b[1515]; void print_q(priority_queue q){ while(!q.empty()){ p2(q.top().F, q.top().S); q.pop(); } puts("---------------------"); } int main(){ li n; cin>>n; rin{cin>>a[i];} rin{cin>>b[i];} li res=n; rin{ li start=i; li tres=n; priority_queue q; rep(j,n)q.push(mp(-a[j], 0)); rep(j,n){ li level_now=q.top().F; li cnt_now=q.top().S; level_now-=(b[start+j%n]/2); q.pop(); q.push(mp(level_now, cnt_now-1)); tres=min(tres, cnt_now-1); //print_q(q); } //cout<