#include #include #include #include using namespace std; struct Monster { Monster(int num, int level) { this->num = num; this->level = level; this->count = 0; } int num; int level; int count; }; int main() { int n; cin >> n; int level_allys[1500]; int level_enemys[1500]; int count_levels[1500]; for (int i = 0; i < n; i++) { cin >> level_allys[i]; } for (int i = 0; i < n; i++) { cin >> level_enemys[i]; } typedef function predicate_type; predicate_type predicate = [](const Monster& left, const Monster& right) { if (left.level > right.level) { return true; } else if (left.level == right.level && (left.count > right.count)) { return true; } else { return false; } }; int ans = numeric_limits::max(); for (int i = 0; i < n; i++) { priority_queue, predicate_type> q(predicate); for (int j = 0; j < n; j++) { q.push(Monster(j, level_allys[j])); count_levels[j] = 0; } for (int j = 0; j < n; j++) { Monster m = q.top(); q.pop(); int target = (i + j) % n; int level = level_enemys[target]; m.level += level / 2; m.count++; count_levels[m.num] = m.count; q.push(m); } int max_count = *max_element(count_levels, count_levels + n); ans = min(ans, max_count); } cout << ans << endl; return 0; }