#include typedef long long ll; typedef unsigned long long ull; #define FOR(i,a,b) for(int (i)=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define RANGE(vec) (vec).begin(),(vec).end() using namespace std; class LevelUpMonster { public: void solve(void) { int N; cin>>N; vector A(N); vector B(N); REP(i, N) cin>>A[i]; REP(i, N) cin>>B[i]; typedef pair Status; // <(level),(battle count)> priority_queue, greater> que; int ans = (1<<30); // O(N^2*log(N)) // 最初に戦う Monster ごとに試す REP(i, N) { REP(i, N) que.emplace(A[i],0); REP(j, N) { int level, count; tie(level, count) = que.top(); que.pop(); que.emplace(level+B[(i+j)%N]/2, count+1); } int max_count = 0; while ( !que.empty() ) { int level, count; tie(level, count) = que.top(); que.pop(); max_count = max(max_count, count); } ans = min(ans, max_count); } cout<solve(); delete obj; return 0; } #endif