Problem:
 Score : 400 points    Problem Statement You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health , and the health of the i -th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.  Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:   Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A , and the health of each of the other monsters will decrease by B . Here, A and B are predetermined parameters, and A > B holds.   At least how many explosions do you need to cause in order to vanish all the monsters?      Constraints  All input values are integers.  1 ≤ N ≤ 10^5  1 ≤ B < A ≤ 10^9  1 ≤ h_i ≤ 10^9         Input Input is given from Standard Input in the following format:  N  A  B  h_1  h_2  :  h_N       Output Print the minimum number of explosions that needs to be caused in order to vanish all the monsters.        Sample Input 1 4 5 3
8
7
4
2      Sample Output 1 2  You can vanish all the monsters in two explosion, as follows:   First, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3 , 4 , 1 and -1 , respectively, and the last monster vanishes.  Second, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0 , -1 and -2 , respectively, and all the monsters are now vanished.        Sample Input 2 2 10 4
20
20      Sample Output 2 4  You need to cause two explosions centered at each monster, for a total of four.       Sample Input 3 5 2 1
900000000
900000000
1000000000
1000000000
1000000000      Sample Output 3 800000000

Solution (Python):
from math import ceil
n,a,b = map(int,input().split())
h = [int(input()) for _ in range(n)]
l = 0
r = max(h)

def f(x):
    res = 0
    for i in range(n): res += ceil(max(0,(h[i]-b*x))/(a-b))
    return res <= x

while l+1 < r:
    m = (l+r)//2
    if f(m): r = m
    else: l = m
print(r)

Solution (Python):
def binsearch(good, bad, fn):
    while abs(good - bad) > 1:
        m = (good + bad) // 2
        if fn(m):
            good = m
        else:
            bad = m
    return good

def main():
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    c = A - B
    def helper(x):
        r = 0
        for h in H:
            r += max((h - B * x + c - 1) // c, 0)
        return r <= x

    return binsearch(10**9, 0, helper)

print(main())

Solution (Python):
import math
def binsearch(l, r, fn):
    while r - l > 1:
        m = (l + r) // 2
        if fn(m):
            l = m
        else:
            r = m
    return l

def main():
    N, A, B = map(int, input().split())
    l = []
    C = A - B
    for _ in range(N):
        h = int(input())
        l.append(h)
    def func(i):
        if max(l) <= B*i:
            return False
        r = 0
        for j in l:
            r += max(math.ceil((j - B*i) / C), 0)
        if r <= i:
            return False
        return True
    return 1 + binsearch(0, 1000000000, func)

print(main())

Solution (Python):
import sys
S=sys.stdin.readlines()
N,A,B=map(int,S[0].split())
H=[int(S[i+1]) for i in range(N)]
L,R=0,10**9
M=0
Z=0
A-=B
while R>L:
  M=(L+R)//2
  Z=0
  for i in range(N):
    Z+=max((H[i]-B*M+A-1)//A,0)
  if Z>M:
    L=max(L+1,M)
  else:
    R=M
print(R)

Solution (Python):
n,a,b=map(int,input().split())
h=[int(input()) for _ in range(n)]
def bisearch(k):
  ret=0
  for hi in h:
    ret+=max(0,(hi-b*k+a-b-1)//(a-b))
  return ret<=k
l,r=0,pow(10,9)
while r-l>1:
  x=(l+r+1)//2
  if bisearch(x):
    r=x
  else:
    l=x

print(r)

Solution (Python):
import sys
readline = sys.stdin.readline

N,A,B = map(int,readline().split())
H = [int(readline()) for i in range(N)]




A -= B

ng = 0
ok = 10 ** 9
def isOk(x):
  
  cnt = 0
  for i in range(len(H)):
    h = H[i] - x * B
    if h > 0:
      cnt += (h + A - 1) // A
  return cnt <= x
  
while abs(ok - ng)>1:
  mid = abs(ok + ng) // 2
  if isOk(mid):
    ok = mid
  else:
    ng = mid

print(ok)

Solution (Python):
n, a, b = map(int, input().split())
c = a-b
h = sorted([int(input()) for _i in range(n)], reverse=True)
left, right = 0, 10**9
while left < right:
    middle = (left+right)//2
    counter = 0
    checker = middle*b
    i = 0
    while checker < h[i]:
        counter -= (-h[i]+checker)//c
        i += 1
        if i >= n:
            break
    if counter <= middle:
        right = middle
    else:
        left = middle + 1
print(right)

Solution (Python):
import numpy as np

n,a,b = map(int,input().split())
h = [int(input()) for _ in range(n)]
h = np.array(h)

hi = 10**10
low = -1

def calc(x):
    y = h-x*b
    y[y<0] = 0
    f = np.ceil(y/(a-b)).sum()
    return f

while hi-low > 1:
    ave = (hi+low)//2
    if calc(ave) <= ave:
        hi = ave
    else:
        low = ave
    
print(hi)

Solution (Python):
N,A,B=map(int,input().split())
H=[int(input()) for _ in range(N)]

def judge(t):
    base_damage=B*t
    add_attack=0
    for hi in H:
        if hi <= base_damage:
            continue
        res=hi-base_damage
        q,r=divmod(res,A-B)
        add_attack+=q
        if r:
            add_attack+=1
    return add_attack<=t

MAX=max(H)
max_attack=MAX//B+1
min_attack=0
while True:
    mid=(min_attack+max_attack)//2
    if mid==min_attack:
        break
    else:
        if judge(mid):
            max_attack=mid
        else:
            min_attack=mid
print(max_attack)

Solution (Python):
N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()


def isOk(k):
    return k >= 0


ok, ng = max(h)//B+1, 0
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    c = mid
    for i in range(N):
        t = h[i]-mid*B
        if t > 0:
            c -= (t+A-B-1)//(A-B)
            if c < 0:
                break
    if isOk(c):
        ok = mid
    else:
        ng = mid

print(ok)

Solution (Python):
N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()


def isOk(k):
    return k >= 0


ok, ng = max(h)//B+1, -1
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    c = mid
    for i in range(N):
        t = h[i]-mid*B
        if t > 0:
            c -= (t+A-B-1)//(A-B)
            if c < 0:
                break
    if isOk(c):
        ok = mid
    else:
        ng = mid

print(ok)

Solution (Python):
import sys
input = sys.stdin.readline

N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
C = A - B

hi = 10**9 + 1
lo = -1

while hi - lo > 1:
    mid = (hi + lo) // 2
    rem = 0
    for i in range(N):
        rem += max(0, (H[i] - B * mid + C - 1) // C)
    if rem <= mid:
        hi = mid
    else:
        lo = mid

print(hi)

Solution (Python):
N,A,B = map(int,input().split())
H = []
for _ in range(N):
    H.append(int(input()))
H = sorted(H)
def check(x):
    cnt = 0
    for h in H:
        if h > x * B:
            tmp = (h - x*B) // (A-B)
            
            if tmp * (A-B) != h - x*B: tmp += 1
            cnt += tmp
    if cnt <= x:
        return True
    else:
        return False

def bisect(l,r):
    if r - l == 1: return r
    mid = (l+r) // 2
    if check(mid):
        return bisect(l,mid)
    else:
        return bisect(mid,r)
    
print(bisect(0,10**12))

Solution (Python):
N,A,B = map(int,input().split())
H = []
for _ in range(N):
    H.append(int(input()))
H = sorted(H)
def check(x):
    cnt = 0
    for h in H:
        if h > x * B:
            tmp = (h - x*B) // (A-B)
            
            if tmp * (A-B) != h - x*B: tmp += 1
            cnt += tmp
    if cnt <= x:
        return True
    else:
        return False

def bisect(l,r):
    if r - l == 1: return r
    mid = (l+r) // 2
    if check(mid):
        return bisect(l,mid)
    else:
        return bisect(mid,r)
    
print(bisect(0,10**31))

Solution (Python):
N,A,B = map(int,input().split())
H = []
for _ in range(N):
    H.append(int(input()))
H = sorted(H)
def check(x):
    cnt = 0
    for h in H:
        if h > x * B:
            tmp = (h - x*B) // (A-B)
            
            if tmp * (A-B) != h - x*B: tmp += 1
            cnt += tmp
    if cnt <= x:
        return True
    else:
        return False

def bisect(l,r):
    if r - l == 1: return r
    mid = (l+r) // 2
    if check(mid):
        return bisect(l,mid)
    else:
        return bisect(mid,r)
    
print(bisect(0,10**28))

Solution (Python):
N,A,B = map(int,input().split())
H = []
for _ in range(N):
    H.append(int(input()))
H = sorted(H)
def check(x):
    cnt = 0
    for h in H:
        if h > x * B:
            tmp = (h - x*B) // (A-B)
            
            if tmp * (A-B) != h - x*B: tmp += 1
            cnt += tmp
    if cnt <= x:
        return True
    else:
        return False

def bisect(l,r):
    if r - l == 1: return r
    mid = (l+r) // 2
    if check(mid):
        return bisect(l,mid)
    else:
        return bisect(mid,r)
    
print(bisect(0,10**20))

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,a,b = map(int, input().split())
hs = [None]*n
for i in range(n):
    hs[i] = int(input())
    
def sub(x):
    vs = [max(item - b*x, 0) for item in hs]
    return sum(v // (a-b) + bool(v % (a-b)) for v in vs) <= x

l = 0
r = 10**9

while l<r-1:
    m = (l+r)//2
    if sub(m):
        r = m
    else:
        l = m
print(r)

Solution (Python):
import sys, math
input = sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    h = [int(input()) for _ in range(n)]
    ok = max(h)
    ng = 0
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        cnt = 0
        for i in range(n):
            cnt += max(0, math.ceil((h[i]-mid*b)/(a-b)))
        if cnt <= mid:
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == "__main__":
    main()

Solution (Python):

def submit():
    n, a, b = (int(e) for e in input().split())
    h = [int(input()) for _ in range(n)]

    
    

    def judge(t):
        base_damage = b * t
        add_attack = 0
        for hi in h:
            if hi <= base_damage:
                continue
            res = hi - base_damage
            q, r = divmod(res, a - b)
            add_attack += q
            if r:
                add_attack += 1
        return add_attack <= t

    max_attack = 0
    for hi in h:
        max_attack += hi // a + 1
    min_attack = 0
    while True:
        mid = (min_attack + max_attack) // 2
        if mid == min_attack:
            break
        else:
            if judge(mid):
                max_attack = mid
            else:
                min_attack = mid

    print(max_attack)

             
if __name__ == "__main__":
    submit()

Solution (Python):
N, A, B = map(int, input().split())
diff = A - B
H = [int(input()) for i in range(N)]

def check(x):
  time = 0
  _H = [h-B*x for h in H]
  for _h in _H:
    if _h > 0:
      time += -(-_h//diff)
  return time <= x

left = 0 
right = 10**10 
while left + 1 < right:
  mid = (left + right) // 2
  if check(mid):
    right = mid
  else:
    left = mid

print(right)

Solution (Python):
n, a, b = map(int, input().split())
h = [int(input()) for i in range(n)]
ng = 0
ok = 10 ** 9
while ok - ng > 1:
  mid = (ok + ng) // 2
  s = 0
  for i in h:
    s += max(0, (i - mid * b + a - b - 1) // (a - b))
  if s <= mid:
    ok = mid
  else:
    ng = mid
print(ok)

Solution (Python):
n, a, b = map(int, input().split())
h = [int(input()) for i in range(n)]
ng = 0
ok = 10 ** 9
while ok - ng > 1:
  mid = (ok + ng) // 2
  s = 0
  for i in h:
    s += max(0, (i - mid * b + a - b - 1) // (a - b))
  if s <= mid:
    ok = mid
  else:
    ng = mid
print(ok)

Solution (Python):
import sys

N, A, B = map(int, sys.stdin.readline().strip().split())

H = []
for _ in range(N):
    H.append(int(sys.stdin.readline().strip()))
H.sort()


left = 1
right = 10**9


ans = right
while left < right:
    mid = (left + right) // 2
    
    n = mid
    for h_i in H:
        if h_i <= B * mid:
            continue

        
        h_i -= B * mid
        n -= (h_i - 1) // (A-B) + 1

    if n >= 0:
        ans = min(ans, mid)
    if n == 0:
        break
    elif n > 0:
        right = mid
    else:
        left = mid + 1

print(ans)

Solution (Python):
import math
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]

def explode(x):
    global n
    c=0
    for i in range(n):
        if h[i]-x*b>0:
            c+=math.ceil((h[i]-x*b)/(a-b))
    return c<=x




l,r=0,10**9

while l+1<r:
    
    
    k=l+(r-l)//2
    
    
    if explode(k):
        r=k
    else:
        l=k

print(r)

Solution (Python):
import math
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]

def explode(x):
    global n
    c=0
    for i in range(n):
        if h[i]-x*b>0:
            c+=math.ceil((h[i]-x*b)/(a-b))
    return c<=x




l,r=1,10**9

while l+1<r:
    
    
    k=l+(r-l)//2
    
    
    if explode(k):
        r=k
    else:
        l=k

print(l if explode(l) else r)

Solution (Python):
import math


def check(k, A, B, H):
    return sum([max([0, math.ceil((h - B * k) / (A - B))]) for h in H]) <= k


def main():
    N, A, B = list(map(int, input().split(' ')))
    H = [int(input()) for _ in range(N)]
    ng, ok = 0, 10**9
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if check(mid, A, B, H):
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == '__main__':
    main()

Solution (Python):
n,a,b=map(int,input().split())
h=[int(input())for _ in range(n)]
h.sort(reverse=True)
l=-1
r=(max(h)-1)//b+1
while r-l>1:
	mid=(l+r)//2
	cnt=0
	for i in range(n):
		if h[i]-b*mid<=0:
			break
		else:
			cnt+=(h[i]-b*mid-1)//(a-b)+1
	if cnt>mid:
		l=mid
	else:
		r=mid
print(r)

Solution (Python):
n,a,b=map(int,input().split())
h=[int(input())for _ in range(n)]
h.sort(reverse=True)
l=-1
r=10**9
while r-l>1:
	mid=(l+r)//2
	cnt=0
	for i in range(n):
		if h[i]-b*mid<=0:
			break
		else:
			cnt+=(h[i]-b*mid-1)//(a-b)+1
	if cnt>mid:
		l=mid
	else:
		r=mid
print(r)

Solution (Python):
N, A, B = map(int,input().split())
h = []
for _ in range(N):
    h.append(int(input()))
 
def solve(n):
    cnt = 0
    for i in h:
        i -= B * n
        cnt += max((i - 1) // (A - B) + 1, 0)
    return cnt <= n
 
left = 0
right = 10 ** 9

while left + 1 < right:
    mid = (left + right) // 2
    if solve(mid):
        right = mid
    else:
        left = mid
 
print(right)

Solution (Python):
from math import ceil

n, a, b = map(int, input().split())
hs = [int(input()) for _ in range(n)]


def defeatable(k):
    hb = [max([h - k * b, 0]) for h in hs]
    n_attack = sum([ceil(h / (a - b)) for h in hb])
    return n_attack <= k


l, r = 0, ceil(max(hs) / b)

while r - l > 1:
    m = (l + r) // 2

    if defeatable(m):
        r = m
    else:
        l = m

print(r)

Solution (Python):


import sys







from bisect import bisect_left, bisect_right 






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    

    def ceil_div_alternative(x, y):
        """
        Args:
            x, y (int)
        Returns:
            int
        
        ceil(x / y) を正確に返す (y を何整数倍すると x 以上になるか？の値)

        >>> ceil_div_alternative(4, 2)
        2
        >>> ceil_div_alternative(4, 3)
        2

        > ceil() 、 floor() 、および modf() 関数については、非常に大きな浮動小数点数が 全て 整数そのものになるということに注意してください。
        > 通常、Python の浮動小数点型は 53 ビット以上の精度をもたない (プラットフォームにおける C double 型と同じ) ので、
        > 結果的に abs(x) >= 2**52 であるような浮動小数点型 x は小数部分を持たなくなるのです。
        > 10 ** 15 + 0.2 == 10 ** 15
        > False
        > 10 ** 16 + 0.2 == 10 ** 16
        > True
        
        x / y が大きな浮動小数点数となる場合は ceil ではなく、この関数を使うようにする。
        """
        assert (isinstance(x, int) and isinstance(y, int))
        assert (x >= 0 and y > 0)
        return (x + y - 1) // y


    def can_defeat_predicate(hp_list, operation_times, a, b):
        n = len(hp_list)
        start = bisect_right(hp_list, b * operation_times)
        if start == n:
            return True
        else:
            res = [hp_list[i] - b * operation_times for i in range(start, n)]
            cnt = 0
            for elm in res:
                cnt += ceil_div_alternative(elm, a - b)
            return cnt <= operation_times


    def binary_search(hp_list, a, b):
        left = 0    
        right = 10**9+1    
        while right - left > 1:
            mid = (right + left) // 2
            if can_defeat_predicate(hp_list, mid, a, b):
                right = mid
            else:
                left = mid
        return right



    n, a, b = mi()
    hp = sorted([ii() for _ in range(n)])
    print(binary_search(hp, a, b))



if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,a,b = inpl()
h = [inp() for _ in range(n)]
ok = 10**12
ng = 0
c = a-b
def chk(x):
    cnt = 0
    for t in h:
        t -= b*x
        if t <= 0: continue
        cnt += (t+c-1)//c
    if cnt <= x:
        return True
    return False
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    if chk(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Solution (Python):
import sys
input = sys.stdin.readline

n, a, b = [int(x) for x in input().split()]
h = [int(input()) for _ in range(n)]

left = 0
right = 10**10

def solve(x):
    remain = []
    for i in h:
        i -= b*x
        if i > 0:
            remain.append(i)
    cnt = 0
    for i in remain:
        cnt += i // (a - b) + int(i % (a - b) != 0)
    if cnt <= x:
        return True
    else:
        return False

while right - left > 1:
    mid = (right + left) // 2
    if solve(mid):
        right = mid
    else:
        left = mid

print(right)

Solution (Python):
import numpy as np
N, A, B = map(int, input().split())
h = np.sort([int(input()) for i in range(N)])

def enough(A, B, h, T):
    h = np.ceil((h - B * T) / (A - B))
    count = sum(h[h > 0])
    
    return True if count <= T else False
right = 10 ** 9
left = 1
while right != left:
    mid = (left + right) // 2
    if enough(A, B, h, mid):
        right = mid
    else:
        left = mid + 1

print(left)

Solution (Python):
import sys
input = sys.stdin.readline
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
t = a-b
r = (max(h)+b-1)//b
l = 0
while r-l > 1:
    m = (r+l)//2
    mi = m*b
    count = 0
    for i in h:
        if i > mi:
            count += (i-mi+t-1)//t
    if count <= m:
        r = m
    else:
        l = m
print(r)

Solution (Python):
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
t = a-b
r = (max(h)+b-1)//b
l = 0
while r-l > 1:
    m = (r+l)//2
    mi = m*b
    count = 0
    for i in h:
        if i > mi:
            count += (i-mi+t-1)//t
    if count <= m:
        r = m
    else:
        l = m
print(r)

Solution (Python):
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
t = a-b
r = 10**9+5
l = 0

while r-l > 1:
    m = (r+l)//2
    mi = m*b
    count = 0
    for i in h:
        if i > mi:
            count += (i-mi+t-1)//t
    if count <= m:
        r = m
    else:
        l = m
print(r)

Solution (Python):
from bisect import bisect_left as bl
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
t = a-b
r = 10**9+5
l = 0

while r-l > 1:
    m = (r+l)//2
    mi = m*b
    count = 0
    for i in h:
        if i > mi:
            count += (i-mi+t-1)//t
    if count <= m:
        r = m
    else:
        l = m
print(r)

Solution (Python):

N, A, B = map(int, input().split())
h = [0] * N
for i in range(N):
    h[i] = int(input())

L = 0
R = sum((h[i]-1) // A + 1 for i in range(N)) + 1
while R - L > 1:
    M = (L+R-1) // 2 + 1
    count = sum((h[i] - B*M - 1) // (A-B) + 1 for i in range(N) if h[i] - B*M > 0)

    if count > M:
        L = M
    else:
        R = M
print((L+R-1) // 2 + 1)

Solution (Python):






import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


def lcm(a, b):
    return a * b // gcd (a, b)





N,A,B = inputIL()
h = inputILs(N)

h.sort()

def count_turn(l,x):
  count = 0
  for i in l:
    count += (i+(x-1))//x
  return count




from bisect import bisect

def is_ok(n):
  h_n = [i-B*n for i in h]
  h_n = h_n[bisect(h_n,0):]
  if n>=count_turn(h_n,A-B):
    return True
  else:
    return False

def meguru_bisect(ng, ok):
  while (abs(ok - ng) > 1):
    mid = (ok + ng) // 2
    if is_ok(mid):
      ok = mid
    else:
      ng = mid
  return ok

ok = h[-1]//B+1
ng = 0
  
print(meguru_bisect(ng, ok))

Solution (Python):
import sys
from math import ceil
"""
def input():
    return sys.stdin.readline().strip()
"""
def check(k):
    tmp = list(h)
    for i in range(N):
        tmp[i] -= B*k
    
    flag = False
    for i in tmp:
        if i > 0:
            flag = True
            break
    if not flag:
        return True

    lf = 0
    for i in tmp:
        if i > 0:
            lf += ceil(i/(A-B))

    if lf <= k:
        return True
    else:
        return False

N,A,B = map(int,input().split())
h = tuple(int(input()) for _ in range(N))

left = -1
right = 1e9

while abs(left-right) > 1:

    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid

print(int(right))

Solution (Python):
import sys
from math import ceil

def input():
    return sys.stdin.readline().strip()

def check(k):
    tmp = list(h)
    for i in range(N):
        tmp[i] -= B*k
    
    flag = False
    for i in tmp:
        if i > 0:
            flag = True
            break
    if not flag:
        return True

    lf = 0
    for i in tmp:
        if i > 0:
            lf += ceil(i/(A-B))

    if lf <= k:
        return True
    else:
        return False

N,A,B = map(int,input().split())
h = tuple(int(input()) for _ in range(N))

left = -1
right = 1e9

while abs(left-right) > 1:

    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid

print(int(right))

Solution (Python):
import sys
from math import ceil

def input():
    return sys.stdin.readline().strip()

def check(k):
    tmp = list(h)
    for i in range(N):
        tmp[i] -= B*k
    if sum([int(i<=0) for i in tmp]) == N:
        return True

    lf = 0
    for i in tmp:
        if i > 0:
            lf += ceil(i/(A-B))

    if lf <= k:
        return True
    else:
        return False

N,A,B = map(int,input().split())
h = tuple(int(input()) for _ in range(N))

left = -1
right = 1e9

while abs(left-right) > 1:

    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid

print(int(right))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import ceil


def check(s):
    cnt = 0
    for hh in h:
        if s * b < hh:
            cnt += ceil((hh - s * b) / (a - b))
    return cnt <= s


n, a, b, *h = map(int, read().split())
low = 0
high = 10 ** 18
while low + 1 < high:
    mid = (low + high) // 2
    if check(mid):
        high = mid
    else:
        low = mid
print(high)

Solution (Python):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B = LI()
    H = [NI() for _ in range(N)]

    h = max(H) // B + 1
    l = 0
    while h > l+1:
        m = (h+l) // 2
        cnt = m
        for x in H:
            if x >= m * B:
                cnt -= math.ceil((x-m*B) / (A-B))
                if cnt < 0: break
        else:
            h = m
            continue
        l = m
    print(h)

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

N, A, B = map(int, input().split())

H = []

for i in range(N):
    H.append(int(input()))

H = np.array(H)

def binary_search(x):
    H_tmp = H - B * x
    H_tmp = H_tmp[H_tmp > 0]
    count = ((H_tmp + A - B - 1) // (A - B)).sum()
    return x >= count

left = 0
right = 10**10

while(right - left > 1):
    mid = (left + right) // 2
    ret = binary_search(mid)
    if ret:
        right = mid
    else:
        left = mid

print(right)

Solution (Python):
def resolve():
    def f(mid):
        return sum([(x - mid * b + a - b - 1) // (a - b) for x in h if x > mid * b]) <= mid
    n, a, b = map(int, input().split())
    h = [int(input()) for _ in range(n)]
    ok, ng = 10 ** 10, 0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if f(mid):
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == '__main__':
    resolve()

Solution (Python):
n, a, b = map(int,input().split())
h = [ int(input()) for i in range(n)]
maxim_h =  max(h)

ok = (maxim_h + a - 1) // a * n
ng = 0
while abs(ok - ng) > 1:

    X = (ok + ng) // 2
    

    cnt = 0
    flag = 1
    for val in h:
        if val <= b * X:continue
        temp = (val - b * X + a - b - 1) // (a - b)
        cnt += temp

        if cnt > X:
            flag = 0
            break

    
    if flag:ok = X
    else:ng = X
print(ok)

Solution (Python):
n,a,b= map(int,input().split())
sh = sorted([int(input()) for i in range(n)],reverse=True)
sumh = sum(sh)
def nibu(t):
    rt=0
    for i in range(n):
        temp = -1*(-1*max(0,sh[i]-t*b)//(a-b))
        if temp>0:rt+=temp
        else:break
        if rt>t:return False
    return True if t>=rt else False
l=max(sh)//a
r=max(sh)//b+1
while r-l!=1:
    m = (l+r)//2
    if nibu(m):r=m
    else:l=m
print(r)

Solution (Python):
n,a,b= map(int,input().split())
sh = sorted([int(input()) for i in range(n)],reverse=True)
sumh = sum(sh)
def nibu(t):
    rt=0
    for i in range(n):
        temp = -1*(-1*max(0,sh[i]-t*b)//(a-b))
        if temp>0:rt+=-1*(-1*max(0,sh[i]-t*b)//(a-b))
        else:break
        if rt>t:return False
    return True if t>=rt else False
l=max(sh)//a
r=max(sh)//b+1
while r-l!=1:
    m = (l+r)//2
    if nibu(m):r=m
    else:l=m
print(r)

Solution (Python):
import sys
input=sys.stdin.readline
N,A,B=map(int,input().split())

hlist=[]
mh=0
for i in range(N):
  h=int(input())
  hlist.append(h)
  mh=max(mh,h)


res_dic={0:False}
def isOK(m):
  if m in res_dic:
    return res_dic[m]
  
  h2list=[]
  mh2=-float("inf")
  for i in range(N):
    h2=hlist[i]-m*B
    h2list.append(h2)
    mh2=max(h2,mh2)
  if mh2<=0:
    res_dic[m]=True
    return res_dic[m]
  
  cnt=0
  for i in range(N):
    if h2list[i]>0:
      cnt+=-(-h2list[i]//(A-B))
      
  res_dic[m]=(cnt<=m)
  return res_dic[m]

l,r=1,-(-mh//B)
while l<=r:
  mid=(l+r)//2
  
  if not isOK(mid-1) and isOK(mid):
    print(mid)
    break
  elif isOK(mid-1):
    r=mid-1
  else:
    l=mid+1

Solution (Python):
import sys
input=sys.stdin.readline
N,A,B=map(int,input().split())

hlist=[]
for i in range(N):
  hlist.append(int(input()))
mh=max(hlist)


def isOK(m):
  if m==0:
    return False
  
  hlist2=list(hlist)
  for i in range(N):
    hlist2[i]-=m*B
  
  if max(hlist2)<=0:
    return True
  
  cnt=0
  for i in range(N):
    if hlist2[i]>0:
      cnt+=-(-hlist2[i]//(A-B))
  return cnt<=m

l,r=1,mh//B+1
while l<=r:
  mid=(l+r)//2
  
  if not isOK(mid-1) and isOK(mid):
    print(mid)
    break
  elif isOK(mid-1):
    r=mid-1
  else:
    l=mid+1

Solution (Python):
import math

N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]


def check(x):
    cnt = 0
    for h in H:
        if h <= B * x:
            continue
        else:
            cnt += math.ceil((h - B * x) / (A - B))

    if cnt <= x:
        return True
    else:
        return False


lb = 0
ub = 10**15
while ub - lb > 1:
    mid = (lb + ub) // 2
    if check(mid):
        ub = mid
    else:
        lb = mid

ans = ub

print(ans)

Solution (Python):
N, A, B, *X = map(int, open(0).read().split())

ub = 10 ** 15
lb = 0
while ub - lb > 1:
    mid = (ub + lb) // 2
    cnt = 0
    for i in range(N):
        if X[i] - B * mid > 0:
            cnt += -(-(X[i] - B * mid) // (A - B))

    if cnt > mid:
        lb = mid
    else:
        ub = mid

print(ub)

Solution (Python):
n,a,b=map(int,input().split())
HP=[int(input()) for i in range(n)]
ng=0
ok=10**10
for i in range(40):
    check=(ok+ng)//2
    c=a-b
    cnt=0
    d=list(map(lambda x: x-check*b,HP))
    for j in d:
        cnt+=max(0,(j+c-1)//c)
    if check < cnt:
        ng=check
    else:
        ok=check
print(ok)

Solution (Python):
def judge(x):
    count = 0
    for hi in h:
        count += max(hi - b*x + c-1, 0)//c 
    if count<=x:
        return True
    else:
        return False

n,a,b=map(int,input().split())
h = [int(input()) for _ in range(n)]

c= a-b

ng = 0
ok = 10**9

while ok - ng > 1:
    mid = (ng+ok)//2
    if judge(mid):
        ok = mid
    else:
        ng = mid
        
print(ok)