use std::{cmp::Reverse, collections::BinaryHeap}; use proconio::input; fn main() { input! { n: usize, a: [usize; n], b: [usize; n], } let mut ans = usize::MAX; for i in 0..n { let mut pq = BinaryHeap::new(); for j in 0..n { pq.push(Reverse((a[j], 0))); } let mut cur = 0; for jj in 0..n { let j = (i + jj) % n; if let Some(Reverse((mut x, mut y))) = pq.pop() { x += b[j]/2; y += 1; cur = cur.max(y); pq.push(Reverse((x, y))); } } if ans > cur { ans = cur; } } println!("{}", ans); }