#include #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() #define pb push_back #define fs first #define sc second #define show(x) cout << #x << " = " << x << endl #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) using namespace std; typedef pair P; int B[1500]; int main(){ int N; cin>>N; priority_queue,greater

> que,qc; rep(i,N){ int a; cin>>a; qc.push(P(a,0)); } rep(i,N) cin>>B[i]; int mn=1e9; rep(i,N){ que=qc; rep(j,N){ P p=que.top(); que.pop(); que.push(P(p.fs+B[(i+j)%N]/2,p.sc+1)); } int mx=0; while(!que.empty()){ P p=que.top(); que.pop(); chmax(mx,p.sc); } chmin(mn,mx); } cout<