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):
N,A,B=map(int,input().split())
H=[int(input()) for i in range(N)]
M=(max(H)+B-1)//B
search=(1,2)
def check(H,k):
    cnt=0
    for i in range(N):
        x=H[i]-k*B
        if x>0:
            cnt+=(x+A-B-1)//(A-B)
    if cnt<=k:return True
    else:return False

mincan=M
maxcant=0
while True:
    k=M*search[0]//search[1]
    if check(H,k):
        if k==maxcant+1:
            ans=k
            break
        mincan=min(mincan,k)
        search=(search[0]*2-1,search[1]*2)
    else:
        if k==mincan-1:
            ans=k+1
            break
        maxcant=max(maxcant,k)
        search=(search[0]*2+1,search[1]*2)
print(ans)

Solution (Python):

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

from math import ceil

ng,ok = 0,10**9+1
while abs(ok-ng)>1:
    mid = (ng+ok)//2
    cnt = 0
    for i in range(N):
        cnt += max(ceil((H[i] - B*mid)/(A-B)) ,0)
    if cnt <= mid:
        ok = mid
    else:
        ng = mid

print(ok)

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007






"""
n = I()
s = IR(n)
su = sum(s)
dp = [[0 for i in range(su+1)] for j in range(n)]
dp[0][s[0]] = 1
for i in range(n):
    dp[i][0] = 1
for i in range(1,n):
    for j in range(su+1)[::-1]:
        if s[i]+j <= su:
            dp[i][s[i]+j] = max(dp[i][s[i]+j],dp[i-1][j])
        dp[i][j] = max(dp[i][j],dp[i-1][j])
for i in range(su+1)[::-1]:
    if dp[n-1][i] == 1 and i%10 != 0:
        break
print(i)
"""


n,a,b = LI()
h = IR(n)
l = 0
r = math.ceil(max(h)/b)
while r-l > 1:
    m = (l+r)//2
    k = 0
    for i in range(n):
        k += max(0,math.ceil((h[i]-b*m)/(a-b)))
        if k > m:break
    if k > m:
        l = m
    else:
        r = m
print(r)

Solution (Python):
from bisect import bisect_right

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

h.sort()

c = a - b
top = h[n - 1] // b + 1
bottom = 1
while top - bottom > 0:
    temp = (top + bottom) // 2
    p = bisect_right(h, temp * b)
    count = 0
    for i in range(p, n):
        count += (h[i] - temp * b) // c
        if h[i] % c != 0:
            count += 1
    if count > temp:
        bottom = temp + 1
    else:
        top = temp
    

print(top)

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


ok, ng = 10 ** 9, 0
while abs(ok - ng) > 1:
    X = (ok + ng) // 2
    H_damaged = [h - (B * X) for h in H if h - (B * X) > 0]
    Need = sum([ceil(h / A) for h in H_damaged])

    if X >= Need:
        ok = X
    else:
        ng = X

print(ok)

Solution (Python):
import math

n,a,b = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort(reverse=True)

def erase(k):
  bomb_time = 0
  for i in h:
    normal_damage = b * k
    if i <= normal_damage:
      break
    i -= normal_damage
    bomb_time += math.ceil(i / (a-b))
    if bomb_time > k:
      return False
  return True

ok = 10**9
ng = 0
while ok-ng > 1:
    mid = (ok+ng)//2
    if erase(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Solution (Python):
n,a,b,*h=map(int,open(0).read().split());i,j=0,2**30
while j-i>1:
 k=c=(j+i)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c<0:i=k
 else:j=k
print(j)

Solution (Python):
n,a,b,*h=map(int,open(0).read().split());i,j=0,max(h)
while j-i>1:
 k=c=(j+i)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c<0:i=k
 else:j=k
print(j)

Solution (Python):
n,a,b,*h=map(int,open(0).read().split());i,j=0,2**47
while j-i>1:
 k=c=(j+i)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c<0:i=k
 else:j=k
print(j)

Solution (Python):
n,a,b,*h=map(int,open(0).read().split());i,j=0,-(-max(h)*n//a)
while j-i>1:
 k=c=(j+i)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c>=0:j=k
 else:i=k
print(j)

Solution (Python):
n,a,b,*h=map(int,open(0).read().split());i,j=0,-(-max(h)*n//a)
while j-i>1:
 k=c=(j+i+1)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c>=0:j=k
 else:i=k
print(j)

Solution (Python):
n,a,b,*h=map(int,open(0).read().split())
i,j=0,-(-max(h)*n//a)
while j-i>1:
 k=c=(j+i+1)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c>=0:j=k
 else:i=k
print(j)

Solution (Python):
n,a,b,*h=map(int,open(0).read().split())
i,j=0,-(-max(h)*n//a)
while True:
  if j-i<2:
    print(j)
    break
  k=c=(j+i+1)//2
  for t in h:
    t-=b*k
    if t>0:
      c+=-t//(a-b)
  if c>=0:
    j=k
  else:
    i=k

Solution (Python):
n,a,b,*h=map(int,open(0).read().split())
i,j=0,-(-max(h)*n//a)
while True:
  if j-i<2:
    print(j)
    break
  k=c=(j+i+1)//2
  for t in h:
    t-=b*k
    if t>0:
      c+=-t//(a-b)
  if c>=0:
    j=k
  else:
    i=k

Solution (Python):
from math import ceil
n,a,b=map(int,input().split())
H=[int(input()) for _ in range(n)]
Mh=max(H)
left,right=Mh//a,Mh//b+1
while right-left>1:
    mid=(left+right)//2
    cnt=0
    for i in range(n):
        cnt+=ceil(max(H[i]-mid*b,0)/(a-b))
    if cnt<=mid:
        right=mid
    else:
        left=mid
print(right)

Solution (Python):
from math import ceil

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

def f(k):
    return sum([ceil((hi-B*k)/(A-B)) for hi in h if hi-k*B>0])<=k

l,r=0,ceil(max(h)/B)

while r-l>1:
    if f((l+r)//2):
        r=(l+r)//2
    else:
        l=(l+r)//2

print(r)

Solution (Python):
import math


def solve(N, A, B, Hs):
    k_min = 1
    k_max = 10 ** 9
    d = A - B
    

    def find(k):
        
        kc = sum([max(math.ceil((h - B * k) / d), 0) for h in Hs])
        return kc <= k

    def bin_search(k_min, k_max):
        if k_max - k_min <= 1:
            if find(k_min):
                return k_min
            return k_max
        
        k_mid = (k_max + k_min) // 2
        m = find(k_mid)
        if m:
            return bin_search(k_min, k_mid)
        else:
            return bin_search(k_mid, k_max)

    return bin_search(k_min, k_max)

if __name__ == "__main__":
    N, A, B = tuple(map(int, input().split(" ")))
    Hs = []
    for _ in range(N):
        Hs.append(int(input()))
    print(solve(N, A, B, Hs))

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

from math import ceil

ng,ok = 0,10**9+1
while abs(ok-ng)>1:
    mid = (ng+ok)//2
    cnt = 0
    for i in range(N):
        cnt += max(ceil((H[i] - B*mid)/(A-B)) ,0)
    if cnt <= mid:
        ok = mid
    else:
        ng = mid

print(ok)

Solution (Python):
import math

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

def check(x):
    defaultDamage = b * x
    cnt = 0
    for h in hList:
        if h > defaultDamage:
            cnt += math.ceil((h - defaultDamage) / (a - b))
    return cnt <= x

left = 0
right = 10 ** 9
while abs(right - left) > 1:
    center = (left + right) // 2
    if check(center):
        right = center
    else:
        left = center
print(right)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))


def check(m):
    cnt = 0
    for i in range(N):
        cnt += max(-(-(h[i]-m*B)//(A-B)), 0)
    return cnt <= m

l = 0
r = 10**9+1
while r-l != 1:
    c = (l+r)//2
    if check(c):
        r = c
    else:
        l = c
print(r)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))


def check(m):
    cnt = 0
    for i in range(N):
        cnt += max(-(-(h[i]-m*B)//(A-B)), 0)
    return cnt <= m


def binary_search(l, r):
    c = (l+r)//2
    if r-l == 1:
        return l if check(c) else r

    if check(c):
        return binary_search(l, c)
    else:
        return binary_search(c, r)

print(binary_search(0, 10**9+1))

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))


def check(m):
    cnt = 0
    for i in range(N):
        cnt += max(-(-(h[i]-m*B)//(A-B)), 0)
    return cnt <= m


def binary_search(l, r):
    c = (l+r)//2
    if r-l == 1:
        return l if check(c) else r

    if check(c):
        return binary_search(l, c)
    else:
        return binary_search(c, r)

print(binary_search(0, 10**9+1))

Solution (Python):
import math




class binarySearch:
    
    def __init__(self, limit):
        self.limit = limit  
        self.t = 0

    
    def condition(self, h, a, b):
        if self.t < 0:
            return False
        count = 0
        for i in range(len(h)):
            if h[i] > b * self.t:
                count += math.ceil((h[i] - b * self.t) / (a - b))
        if count > self.t:
            return False
        else:
            return True

    def search(self, h, a, b):
        low = 0
        high = self.limit
        self.t = int((low + high) / 2)
        while high >= low:
            out = self.condition(h, a, b)
            if not out:
                low = self.t + 1
            else:
                high = self.t - 1
            self.t = int((low + high) / 2)
        return self.t + 1


n, a, b = [int(i) for i in input().split()]
h = [0 for _ in range(n)]
for i in range(n):
    h[i] = int(input())
binary = binarySearch(limit=math.ceil(max(h) / 1))
print(binary.search(h, a, b))

Solution (Python):
import math


class binarySearch:
    
    def __init__(self, limit, target):
        self.limit = limit
        self.target = target
        self.t = 0

    def condition(self, h, a, b):
        if self.t < 0:
            return False
        count = 0
        for i in range(len(h)):
            if h[i] > b * self.t:
                count += math.ceil((h[i] - b * self.t) / (a - b))
        if count > self.t:
            return False
        else:
            return True

    def search(self, h, a, b):
        low = 0
        high = self.limit
        self.t = int((low + high) / 2)
        while high >= low:
            out = self.condition(h, a, b)
            
            if not out:
                low = self.t + 1
            else:
                high = self.t - 1
            self.t = int((low + high) / 2)
        
        return self.t + 1


def func(a, b, _h):
    _h.sort()
    _h.reverse()
    _sum = 0  
    aMargin = 0  
    for h in _h:
        print("prev cost upper:{}".format(a * aMargin + b * (_sum - aMargin)))
        
        if h <= a * aMargin + b * (_sum - aMargin):
            
            h -= b * _sum  
            if h > 0:
                aMargin -= math.ceil(h / (a - b))  
        else:
            
            tmpH = h
            tmpH -= a * aMargin + b * (_sum - aMargin)
            extra = math.ceil(tmpH / a)
            _sum += extra
            aMargin += extra
            print("aMargin:{}".format(aMargin))
            
            
            
            h -= b * _sum  
            aMargin -= math.ceil(h / (a - b))  
        print("_sum:{} margin:{}".format(_sum, aMargin))
    return str(_sum)


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

binary = binarySearch(target=math.ceil(max(h) / a), limit=math.ceil(max(h) / 1))
print(binary.search(h, a, b))

"""
print("2 vs " + func(5, 3, [8, 7, 4, 2]))
print("4 vs " + func(10, 4, [20, 20]))
print("800000000 vs " + func(2, 1, [900000000, 900000000, 1000000000, 1000000000, 1000000000]))
"""

Solution (Python):
import math
import copy

def condition(t, h, a, b):
    count = 0
    for i in range(len(h)):
        if h[i] > b*t:
            count += math.ceil((h[i]-b*t)/(a-b))
    
    if count > t:
        return False
    else:
        return True


class binarySearch:
    
    
    def __init__(self, limit, target):
        self.limit = limit
        self.target = target

    def search(self, h, a, b):
        low = 0
        high = self.limit
        t = int((low + high) / 2)
        while high >= low:
            out = condition(t, h, a, b)
            
            if not out:
                low = t + 1
            else:
                high = t - 1
            t = int((low + high) / 2)
        for i in range(3):
            if condition(low-i, h, a, b):
                return low-i
        

def func(a, b, _h):
    _h.sort()
    _h.reverse()
    _sum = 0  
    aMargin = 0  
    for h in _h:
        print("prev cost upper:{}".format(a * aMargin + b * (_sum - aMargin)))
        
        if h <= a * aMargin + b * (_sum - aMargin):
            
            h -= b * _sum  
            if h > 0:
                aMargin -= math.ceil(h / (a - b))  
        else:
            
            tmpH = h
            tmpH -= a * aMargin + b * (_sum - aMargin)
            extra = math.ceil(tmpH / a)
            _sum += extra
            aMargin += extra
            print("aMargin:{}".format(aMargin))
            
            
            
            h -= b * _sum  
            aMargin -= math.ceil(h / (a - b))  
        print("_sum:{} margin:{}".format(_sum, aMargin))
    return str(_sum)


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

binary = binarySearch(target=math.ceil(max(h)/a), limit=math.ceil(max(h)/1))
print(binary.search(h, a, b))

"""
print("2 vs " + func(5, 3, [8, 7, 4, 2]))
print("4 vs " + func(10, 4, [20, 20]))
print("800000000 vs " + func(2, 1, [900000000, 900000000, 1000000000, 1000000000, 1000000000]))
"""

Solution (Python):
import sys
N,A,B=map(int, raw_input().split()) 
H=[ int(sys.stdin.readline()) for i in range(N) ] 

def func(n , T):
	sa=A-B
	k=0
	for x in T:
		x-=n*B
		if x>0:
			if x%sa==0:
				k+=x/sa
			else:
				k+=(x/sa+1)
		
			if n<k:
				return False
	else:
			return True

l=0
r=10**9
while l!=r:
	m=(r+l)/2
	if func(m,H):
		r=m
	else:
		l=m+1

print l

Solution (Python):
import sys
N,A,B=map(int, raw_input().split()) 
H=[ int(sys.stdin.readline()) for i in range(N) ] 

def func(n , T):
	sa=A-B
	k=0
	for x in T:
		x-=n*B
		if x>0:
			if x%sa==0:
				k+=x/sa
			else:
				k+=(x/sa+1)
		
			if n<k:
				return False
	else:
			return True

l=0
r=max(H)/B+1
while l!=r:
	m=(r+l)/2
	if func(m,H):
		r=m
	else:
		l=m+1
	

print l

Solution (Python):
from math import ceil

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

A -= B  


ok, ng = 10 ** 9, 0
while abs(ok - ng) > 1:
    X = (ok + ng) // 2

    h = [max(hi - B * X, 0) for hi in H]
    h = [ceil(hi / A) for hi in h]

    if sum(h) <= X:
        ok = X
    else:
        ng = X

print(ok)

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


def enough(x):
    return sum([1 + (max(h - B * x, 0) - 1) // (A - B) for h in H]) <= x


ng = 0
ok = 1 + (max(H) - 1) // B

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

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


def add_attack(t):
    attack = B * t
    for i in range(N):
        h = h_list[i]
        h -= attack
        if h > 0:
            t -= (h + (A - B) - 1) // (A - B)
            if t < 0:
                return False
    return True


t_min = 1
t_max = (h_max + B - 1) // B

while t_min < t_max - 1:
    t_mid = (t_min + t_max) // 2
    if add_attack(t_mid):
        t_max = t_mid
    else:
        t_min = t_mid
print(t_max)

Solution (Python):
N, A, B = map(int, input().split())
h_list = [int(input()) for _ in range(N)]
h_list.sort(reverse=True)
h_max = h_list[0]


def add_attack(t):
    attack = B * t
    for i in range(N):
        h = h_list[i]
        h -= attack
        if h > 0:
            t -= (h + (A - B) - 1) // (A - B)
            if t < 0:
                return False
    return True


t_min = 1
t_max = (h_max + B - 1) // B

while t_min < t_max - 1:
    t_mid = (t_min + t_max) // 2
    if add_attack(t_mid):
        t_max = t_mid
    else:
        t_min = t_mid
print(t_max)

Solution (Python):
def judge(h,t,a,b,n):
    counter = 0
    for i in range(n):
        if h[i] > b*t:
            if ((h[i]-b*t)/(a-b))%1 == 0:
                counter += (h[i]-b*t)//(a-b)
            else:
                counter += (h[i]-b*t)//(a-b) + 1
    if counter <= t:
        return True
    else:
        return False

n,a,b = map(int,input().split())
h = []
for i in range(n):
    temp = int(input())
    h.append(temp)

left = 1
right = max(h)//b + 1

while abs(right-left) > 1:
    check = judge(h,(left+right)//2,a,b,n)
    if check:
        right = (left+right)//2
    else:
        left = (left+right)//2

if judge(h,left,a,b,n):
    print(left)
else:
    print(right)

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

h = [int(m) for m in d]


low = 0
high = math.ceil(max(h)/b)

t = (low + high) // 2



X = 0
Y = 0
s = 0
while high - low >= 0:
    for j in range(n):
        X += max(0, math.ceil((h[j] - t * b) / (a - b)))
        
    if X == t:
        print(t)
        exit()
    elif X < t:
        high = t - 1
        """for j in range(n):
            Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))"""
    elif X > t:
        low = t + 1
    s = t
    t = (low + high) // 2
    X = 0
    Y = 0
for j in range(n):
  if math.ceil((h[j] - s * b) / (a - b)) > 0:
            Y += math.ceil((h[j] - s * b) / (a - b))
if Y <= s:
  print(s)
else:
  print(s + 1)

Solution (Python):
from math import ceil

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

max(h)

l = 0
r = ceil(max(h) / B) + 1

ans = float('inf')
while l < r:
    t = 0
    cnt = (l + r) // 2
    for i in range(N):
        if h[i] > cnt * B:
            t += ceil((h[i] - cnt * B) / (A - B))
    if t <= cnt:
        ans = min(ans, cnt)
        r = cnt
    else:
        l = cnt + 1

print(ans)

Solution (Python):
import math
n,a,b=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
def sten(t):
    dh=[]
    for i in range(n):
        if h[i]-t*b>0:
            dh.append(h[i]-t*b)
    aan=0
    for i in range(len(dh)):
        aan+=math.ceil(dh[i]/(a-b))
    if aan<=t:
        return True
    else:
        return False

left = 0
right = int(1e9)
while left < right:
    center = (left + right) // 2
    if sten(center):
        right = center
    else:
        left = center + 1
print(left)

Solution (Python):
def check(n, H, A, B):
    s = 0
    for h in H:
        s += max(-(-(h - n*B) // (A-B)), 0)
    if s <= n:
        return True
    else:
        return False


def main():
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    left = 0
    right = int(1e9)
    while left < right:
        center = (left + right) // 2
        if check(center, H, A, B):
            right = center
        else:
            left = center + 1
    print(left)


if __name__ == "__main__":
    main()

Solution (Python):
import math
N,A,B=map(int,input().split())
H=[int(input()) for i in range(N)]
left=1
right=10**10
while left!=right:
  x=(left+right)//2
  S=0
  for i in range(N):
    if H[i]-B*x>=0:
      S+=math.ceil((H[i]-B*x)/(A-B))
  if S<=x:
      right=x
  else:
      left=x+1
print(left)

Solution (Python):
import math

N,A,B=list(map(int,input().split()))
arr=[]
h_sum=0
for i in range(N):
    h=int(input())
    arr.append(h)
    h_sum+=h

max_=max(arr)//B+1
min_=h_sum//(A+B*(N-1))

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    sum_=0
    for x in arr:
        y=(x-mid*B)
        if y<=0:
            continue
        sum_+=math.ceil(y/d)
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)

Solution (Python):
import math        
    
N,A,B=list(map(int,input().split()))
arr=[]

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

max_=max(arr)//B+1
min_=min(arr)//A

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    sum_=0
    for x in arr:
        y=(x-mid*B)
        if y<=0:
            continue
        sum_+=math.ceil(y/d)
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)

Solution (Python):
import math
"""
def search(min_,max_,A,B,arr):

    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=arr-mid*B
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=map(lambda x:math.ceil(x/(A-B)),tmp)
    sum_=sum(list(tmp))
    if sum_<=mid:
        return search(min_,mid,A,B,arr)
    else:
        return search(mid+1,max_,A,B,arr)

    while True:
        if k<0:
            if mid==min_:
                return max_
            else:
                
                return search(mid,max_,A,B,arr[:L])
        elif len(tmp)==0:
            
            return search(min_,mid,A,B,arr)
        x=-tmp[0]
        tmp=np.delete(tmp,0)
        k-=x//(A-B)+(x%(A-B)>0)
"""
        
    
N,A,B=list(map(int,input().split()))
arr=[]

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

max_=max(arr)//B+1
min_=min(arr)//A

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    sum_=0
    for x in arr:
        sum_+=max(0,math.ceil((x-mid*B)/d))
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)

Solution (Python):
import sys
import math


def solve_rec(n, a, b, h_lst, ans_min, ans_max):
    if ans_min == ans_max:
        return ans_min

    if ans_min > ans_max:
        return -1

    pivot = (ans_min + ans_max) // 2
    
    is_beatable = beatable(a, b, h_lst, pivot)

    if is_beatable:
        
        return solve_rec(n, a, b, h_lst, ans_min, pivot)
    else:
        
        return solve_rec(n, a, b, h_lst, pivot+1, ans_max)

def beatable(a, b, h_lst, pivot):
    
    living = [ h - b * pivot for h in h_lst if h > b * pivot ]
    

    
    c = sum([ math.ceil(1.0 * h / (a-b)) for h in living ])
    
    return c <= pivot

def solve(n, a, b, h_lst):
    h_max = max(h_lst)
    ans_min = 0
    ans_max = h_max // b + 1

    return solve_rec(n, a, b, h_lst, ans_min, ans_max)

def main():
    line = sys.stdin.readline()
    lst = line.split()
    n = int(lst[0])
    a = int(lst[1])
    b = int(lst[2])

    h_lst = []
    for i in range(n):
        line = sys.stdin.readline()
        h = int(line)
        h_lst.append(h)
        

    ans = solve(n, a, b, h_lst)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
from math import ceil
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]

A = A - B
ng, ok = 0, 10 ** 9 + 1
while abs(ok - ng) > 1:
    X = (ng + ok) // 2
    H_damaged = [h - B * X for h in H]
    need = sum([max(ceil(h / A), 0) for h in H_damaged])

    if need <= X:
        ok = X
    else:
        ng = X

print(ok)

Solution (Python):
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def is_cond(T, A, B, h):

    s = 0
    for i in range(len(h)):
        h_new = h[i] - B*T
        if h_new > 0:
            s += h_new / (A - B) + (0 if h_new % (A - B) == 0 else 1)

    return s <= T

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, A, B] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2])]
    h = []
    for i in range(N):
        input_raw = read_func().strip().split()
        h.append(long(input_raw[0]))
    
    l = 0L
    r = max(h)/B + 1
    while(1):
        
        if abs(l - r) <= 1:
            print r
            break
        T = (l + r)/2
        if is_cond(T, A, B, h) == True:
            r = T
        else:
            l = T


if __name__ == '__main__':
    main()

Solution (Python):
N, A, B = map(int, input().split())
h = []

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

def bool(n, h):
    h.sort()
    damage = n * B
    hx = list(map(lambda x: x - damage, h))
    count = 0
    for i in range(len(hx)):
        count += max(0, 1 + (hx[i]-1) // (A - B))
    if count > n:
        return False
    else:
        return True
start = 0
end = 10000000000
while end - start > 1:
    mean = (start + end)//2
    if bool(mean, h):
        end = mean
    else:
        start = mean

print(end)

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


def enough(T):
    num = 0
    for i in range(N):
        if H[i] - B * T > 0:
            num += (H[i] - B * T) // (A - B)
            num += int((H[i] - B * T) % (A - B) != 0)
    return T >= num


left, right = 0, 10 ** 9 + 1
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    if enough(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)]
H.sort()
from math import ceil
def KnockOut(t):
    base = B*t
    for i in range(N):
        h = H[i]
        h -= base
        if h > 0:
            t -= ceil(h/(A-B))
            if t < 0:
                return False
    return True
l = 0
r = ceil(max(H)/B)
while l != r-1:
    t = int((l+r)/2)
    if KnockOut(t):
        r = t
    else:
        l = t
print(r)

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

def judge(t):
    res=0
    for x in h:
        if x-b*t>0:
            res+=-(-(x-b*t)//(a-b))
    return res<=t
low=0
high=10**9+1
while high-low>1:
    mid=(low+high)//2
    if judge(mid):
        high=mid
    else:
        low=mid
print(high)

Solution (Python):
def roof(a, b):
    if a%b == 0:
        return a//b
    else:
        return a//b + 1

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

low, high = 0, 10**9
while high - low > 1:
    mid = (low + high)//2
    count = 0
    for i in range(N):
        if H[i] - (B * mid) > 0:
            count += roof(H[i]-(B*mid), A-B)
    if count > mid:
        low = mid
    else:
        high = mid
print(high)

Solution (Python):
from math import ceil
N, A, B = map(int,input().split())
h = []
for k in range(N):
    h.append(int(input()))

def check(t):
    s = t
    for k in range(N):
        if h[k] > B*t:
            s -= ceil((h[k]-B*t)/(A-B))
        if s < 0:
            return False
    return True

lo = 0
hi = max(h)+1

while hi - lo > 1:
    mid = (hi+lo)//2
    if check(mid):
        hi = mid
    else:
        lo = mid

print(hi)

Solution (Python):
import math

def f(h, a, b, t):
    y = 0
    for hi in h:
        if hi-b*t <= 0:
            break
        else:
            y += math.ceil((hi-b*t)/(a-b))
    if y <= t:
        return True
    else:
        return False

n, a, b = list(map(int, input().split()))
h = []
for _ in range(n):
    h.append(int(input()))
h.sort(reverse=True)

low = 0
high = math.ceil(h[0]/b)

while True:
    m = (low+high)//2
    if f(h,a,b,m):
        high = m
    else:
        low = m
    if low +1 == high:
        break

print(high)

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

left = 0
right = 10**10
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    count = 0
    for i in range(n):
        if h[i] - mid * b > 0:
            if (h[i] - mid * b) % (a - b) == 0:
                count += (h[i] - mid * b) // (a - b)
            else:
                count += (h[i] - mid * b) // (a - b) + 1
    if mid - count >= 0:
        right = mid
    else:
        left = mid
print(right)

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

left = 0
right = 10**10
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    count = 0
    for i in range(n):
        if h[i] - mid * b > 0:
            if (h[i] - mid * b) % (a - b) == 0:
                count += (h[i] - mid * b) // (a - b)
            else:
                count += (h[i] - mid * b) // (a - b) + 1
    if mid - count >= 0:
        right = mid
    else:
        left = mid
print(right)

Solution (Python):


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


def ok(t):
    count = 0
    for h in H:
        if h - b*t > 0:
            count += -(-(h - b*t) // (a - b))
    return count <= t


lo = 0
hi = 10**9+1
while hi - lo > 1:
    mid = (lo + hi) // 2
    if ok(mid):
        hi = mid
    else:
        lo = mid
print(hi)

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

left = 0
right = 10**10
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    count = 0
    for i in range(n):
        if h[i] - mid * b > 0:
            if (h[i] - mid * b) % (a - b) == 0:
                count += (h[i] - mid * b) // (a - b)
            else:
                count += (h[i] - mid * b) // (a - b) + 1
    if mid - count >= 0:
        right = mid
    else:
        left = mid
print(right)

Solution (Python):
n,a,b = map(int,input().split())
lis = [int(input()) for i in range(n)]
more = a-b

def tansaku(x):
  cou = 0
  normal = b * x
  for hp in lis:
    r = hp -normal
    if r <= 0:continue
    cou += r // more
    
    if r % more != 0:
      cou += 1
  return cou <= x

left = 1
right = max(lis)
while right - left > 1:
  mid = (right + left)//2
  if tansaku(mid):
    right = mid
  else:
    left = mid
print(right)