main = mapM_ (print. solve) . analyze . map read . words =<< getContents
analyze (n:a:b:cs) = let (hs,as) = splitAt n cs in (n,a,b,hs):analyze as
analyze _ = []
solve (n,a,b,hs) = f 0 (maximum $ map (\h->(h+b-1)`div`b) hs) where
  f lo hi
    |lo+1>=hi = hi
    |r>m = f m hi
    |otherwise = f lo m
    where
      m = (lo+hi)`div`2
      r = sum . map g $ hs
      g h = if h<=m*b then 0 else (h-m*b+(a-b)-1)`div`(a-b)