#include using namespace std; template istream& operator>>(istream& is, pair& a){ return is >> a.first >> a.second; } template ostream& operator<<(ostream& os, pair& a){ return os << a.first << " "< istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; } template ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; } #define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++) #define ALL(v) (v).begin(), (v).end() #define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());} #define fr first #define sc second typedef pair< int , int > Pi; typedef pair< int , Pi > Pii; typedef long long int64; const int INF = 1 << 30; int main(){ int N; cin >> N; vector< int > A(N), B(N); cin >> A; cin >> B; int ret = INF; priority_queue< Pi, vector< Pi >, greater< Pi > > que; for(int i = 0; i < N; i++){ /* 最初に戦うモンスター */ for(int j = 0; j < N; j++) que.push( Pi( A[j], 0)); int res = 0; int cnt = 0; while(!que.empty()) { int pos = (i + cnt) % N; Pi p = que.top(); que.pop(); /* 一番低いモンスター */ int next_Cost = p.first + B[pos] / 2; res = max( res, p.second + 1); que.push( Pi( next_Cost, p.second + 1)); ++cnt; } ret = min( ret, res); } cout << ret << endl; }