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):
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def mera(n: int, hp:list, a:int, b:int) -> bool:
    hp = [hpi - n*b for hpi in hp]
    
    center = 0
    for hpi in hp:
        if hpi <= 0:
            continue
        else:
            center += (hpi//(a-b) + bool(hpi%(a-b)))

    if center > n:
        return False
    else:
        return True
    

n,a,b = li()
hp = [ni() for _ in range(n)]


low = 0
high = max(hp)//b+1

while high - low > 1:
    mid = (high+low) // 2
    if mera(mid,hp,a,b):
        high = mid
    else:
        low = mid
        

print(high)

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

lo, hi = -1, 10**9
while hi - lo > 1:
    X = (hi + lo) // 2
    H2 = [max(0, h - (X * B)) for h in H]
    need = sum([ceil(h / C) for h in H2])
    if need > X:
        lo = X
    else:
        hi = X

print(hi)

Solution (Python):
N,A,B = map(int,input().split())
hs = [int(input()) for i in range(N)]
hs.sort(reverse=True)

def defeat(atk):
    if atk*B >= hs[0]:
        return True
    count = 0
    for h in hs:
        if h <= atk*B: break
        rem = h - atk*B
        count += -(-rem//(A-B))
        if count > atk:
            return False
    return True

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

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def ok(n, A, B, H):
    num = 0
    for h in H:
        r = h - n * B
        if r > 0:
            num += ceil(r, (A - B))
    return num <= n


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

    low, high = 0, 10 ** 10
    ans = 0
    while high - low > 1:
        middle = (low + high) // 2
        if ok(middle, A, B, H):
            ans = middle
            high = middle
        else:
            low = middle

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N, A, B = map( int, input().split())
hmax = 0
H = [ int( input()) for _ in range(N)]
hmax = max(H)
L = 0
R = hmax//B + 1
add = A-B
while R-L != 1:
    now = (L+R)//2
    need = 0
    for i in range(N):
        r = H[i] - now*B
        if r > 0:
            need += (r-1)//add+1
    if need <= now:
        R = now
    else:
        L = now
print(R)

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

L = 0
R = 10**9+1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        r = H[i] - now*B
        if r > 0:
            need += (r-1)//add+1
    if need <= now:
        R = now
    else:
        L = now+1
print(L)

Solution (Python):
N, A, B = map( int, input().split())
hmax = 0
H = [ int( input()) for _ in range(N)]
hmax = max(H)
L = 0
R = hmax//B + 1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        r = H[i] - now*B
        if r > 0:
            need += (r-1)//add+1
    if need <= now:
        R = now
    else:
        L = now+1
print(L)

Solution (Python):
N, A, B = map( int, input().split())
H = [0]*N
hmax = 0
for i in range(N):
    h = int( input())
    H[i] = h
hmax = max(H)
L = 0
R = hmax//B + 1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        r = H[i] - now*B
        if r > 0:
            need += (r-1)//add+1
    if need <= now:
        R = now
    else:
        L = now+1
print(L)

Solution (Python):
N, A, B = map( int, input().split())
H = [0]*N
hmax = 0
for i in range(N):
    h = int( input())
    H[i] = h
hmax = max(H)
L = 0
R = hmax//B + 1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        if H[i] > now*B:
            need += (H[i]-1-now*B)//add + 1
    if need <= now:
        R = now
    else:
        L = now+1
print(L)

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

L = 0
R = hmax//B + 1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        if H[i] > now*B:
            need += (H[i]-1-now*B)//add + 1
    if need <= now:
        R = now
    else:
        L = now+1
print(L)

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

L = 0
R = hmax//B + 1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        if H[i] > now*B:
            need += (H[i]-1-now*B)//add + 1
    if need <= now:
        R = now
    else:
        L = now+1
print(L)

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

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


def is_OK(x):
    cnt = 0
    for hi in h:
        hi -= B * x
        if hi > 0:
            if hi % (A - B) == 0:
                cnt += hi // (A - B)
            else:
                cnt += hi // (A - B) + 1
    return cnt <= x


left = 0
right = sum(h) // A + N
while right - left > 1:
    mid = (left + right) // 2
    if is_OK(mid):
        right = mid
    else:
        left = mid
print(right)

Solution (Python):
n,a,b=map(int,input().split())
h=[int(input()) for _ in [0]*n]
f=lambda n:lambda x:x-b*n

def calc(n):
  g=f(n)
  k=lambda x:1+x//(a-b) if x%(a-b) else x//(a-b)
  o=filter(lambda x:x>0,map(g,h))
  *p,=map(k,o)
  if not p:
    return True
  else:
    return sum(p)<=n

l,r=0,max(h)
while r-l>1:
  m=(r+l)//2
  if calc(m):
    r=m
  else:
    l=m
print(r)

Solution (Python):
import math
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
def cheak(x):
  kiso = b*x
  kai = 0
  for i in h:
    if kiso < i:
      kai += math.ceil((i-kiso)/(a-b))
  if kai > x:
    return 0
  else:
    return 1
dai = max(h)
syo = 0
while True:
  if dai-syo == 1:
    break
  kon = (dai+syo)//2
  c = cheak(kon)
  if c == 1:
    dai = kon
  else:
    syo = kon
print(dai)

Solution (Python):

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

def check(j):
    cnt = 0
    for i in range(n):
        tmp = math.ceil((h[i] - b*j) / (a-b))
        if tmp <= 0:
            pass
        else:
            cnt += tmp
    if cnt <= j:
        return True
    else:
        return False


def bs(l,r):
    while l != r:
        m = (l+r)//2
        if check(m):
            r = m
        else:
            l = m+1
    return l

print(bs(0, 10**9))

Solution (Python):
from math import ceil
N, A, B = map(int, raw_input().split())
h = [0] * N
for i in range(N):
  h[i], = map(int, raw_input().split())
h.sort()

l = 0
r = int(ceil(1.0*h[-1]/B))
while True:
  m = (l+r)//2
  if m==l:
    break
  c = 0
  for i in range(N):
    ai = int(ceil(1.0*max(0,h[i]-B*m)/(A-B)))
    c += ai
  if c>m:
    l = m
  else:
    r = m
print r

Solution (Python):
import math
N, A, B = map(int, input().split())
H = [0] * N
maxh = 0
for i in range(N):
  h = int(input())
  H[i] = h
  maxh = max(h, maxh)
lower = 0
upper = math.ceil(maxh / B)
def search(upper, lower):
  if lower + 1 == upper:
    return upper
  else:
    mid = (upper + lower) // 2
    _H = [h - mid * B for h in H]
    cnt = 0
    for h in _H:
      if h > 0:
        cnt += math.ceil(h / (A - B))
    if cnt <= mid:
      return search(mid, lower)
    else:
      return search(upper, mid)
print(search(upper, lower))

Solution (Python):
import sys,math

N,A,B=map(int,input().split())
H = [0] * N
H = [int(input()) for i in range(N)]
 
maxH = max(H)
L=-1
R=math.ceil(maxH / B)

while R-L>1:
    MID=(L+R)//2
    if sum(math.ceil(max(h-B*MID,0)/(A-B))for h in H)>MID:
        L=MID
    else:
        R=MID

print(R)

Solution (Python):
import math

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

maxH = max(H)
L=-1
R=math.ceil(maxH / B)

def binary_search(D,U):
    MID=(D+U)//2
    if(MID==D):
        print(U)
    else:
        if sum(math.ceil(max(h-B*MID,0)/(A-B))for h in H)<=MID:
            binary_search(D,MID)
        else:
            binary_search(MID,U)


binary_search(L,R)

Solution (Python):
from math import ceil

N,A,B = map(int, input().split())
H = []
for i in range(N):
    H.append(int(input()))
    
H.sort(reverse=True)


def enough(T:int) -> bool:
    normal = B*T   
    addit = A-B    
    
    cnt = 0        
    for h in H:
        need_add = ceil((h-normal) / addit)
        if need_add > 0:
            cnt += need_add
        
    return cnt <= T



def search() -> int:
    low = 0             
    high = 10**9 + 1    
    
    
    while high - low > 1:
        mid = (high + low) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
            
    return high

print(search())

Solution (Python):
import math

def solve():
    n, a, b = list(map(int, input().split()))
    h = [int(input()) for _ in range(n)]
    h = sorted(h)

    def is_enough(t):
        t_check = 0
        for hh in h:
            hh -= b*t
            if hh > 0:
                t_check += math.ceil(hh/(a-b))
        if t_check > t: return False
        else: return True

    t_min = 1
    t_max = h[-1]//b+1 
    while t_min != t_max-1:
        t_next = (t_min+t_max)//2
        if is_enough(t_next):
            t_max = t_next
        else:
            t_min = t_next
        

    if is_enough(t_min): print(t_min)
    else: print(t_max)
    return

solve()

Solution (Python):


import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(N, A, B, H):
    H.sort(reverse=True)

    def e(t):
        b = B*t
        a = A-B
        for h in H:
            h -= b
            if h > 0:
                t -= int(math.ceil(h/a))
        return t >= 0

    l = 0
    r = max(H)
    while r - l > 1:
        m = (r+l)//2
        if e(m):
            r = m
        else:
            l = m

    return r


def main():
    N, A, B = read_int_n()
    H = [read_int() for _ in range(N)]

    print(slv(N, A, B, H))


if __name__ == '__main__':
    main()

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

import bisect, math
def f(ll, ul):
    if ul == ll: return ll
    cur = (ll + ul) // 2
    r = H[bisect.bisect_right(H, B * cur):]
    p = sum(math.ceil((x - B * cur) / (A - B)) for x in r)

    if p <= cur:
        return f(ll, cur)
    else:
        return f(cur + 1, ul)

print(f(0, math.ceil((H[-1]) / B)))

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

import bisect, math
def f(ll, ul):
    if ul == ll: return ll
    cur = (ll + ul) // 2
    r = H[bisect.bisect_right(H, B * cur):]
    p = sum(math.ceil((x - B * cur) / (A - B)) for x in r)

    if p == cur:
        return cur
    elif p < cur:
        return f(ll, cur)
    else:
        return f(cur + 1, ul)

print(f(0, math.ceil((H[-1]) / B)))

Solution (Python):
import math
n, a, b = map(int,input().split(' '))

h = [ 0 for i in range(n)]

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

for i in range(n):
    h[i]=int(input())

x_max = max(h)
x_min = 0
while(x_max - x_min > 1):
    x_mid = (x_max + x_min)//2
    if(enough(x_mid)):
        x_max = x_mid
    else:
        x_min = x_mid

print(x_max)

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

ab = A - B


def check(t):
    cnt = 0
    bt = B * t
    for hi in h:
        r = hi - bt
        if r <= 0:
            continue
        cnt += r // ab
        if r % ab:
            cnt += 1
    return cnt <= t


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

Solution (Python):
import math
N, A, B = map(int, input().split())
H = [0] * N
H = [int(input()) for i in range(N)]
maxH = max(H)
U = math.ceil(maxH / B)
L = 0
def binsearch(U, L):
  m = (U + L) // 2
  if m == L:
    print(U)
  else:
    if sum([math.ceil(max(h - B * m, 0) / (A - B)) for h in H]) <= m:
      binsearch(m, L)
    else:
      binsearch(U, m)
binsearch(U, L)

Solution (Python):
import math

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


def check(t):
    cnt = 0
    ab = A - B
    bt = B * t
    for i in range(N):
        r = (h[i] - bt)
        if r <= 0:
            continue
        cnt += r // ab
        if r % ab:
            cnt += 1
    return cnt <= t


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

Solution (Python):
import math

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


def check(t):
    cnt = 0
    ab = A - B
    bt = B * t
    for i in range(N):
        cnt += max(0, math.ceil((h[i] - bt) / ab))
    return cnt <= t


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

Solution (Python):
import math

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


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


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

Solution (Python):
import sys
from math import ceil, floor
n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]

def enough(t):
    cnt = 0
    for h in H:
        
        rh = h - b * t
        if rh <= 0:
            continue
        cnt += rh//(a-b)
        if rh%(a-b) != 0:
            cnt += 1
    if cnt <= t:
        return True
    else:
        return False

bot = floor(sum(H)/(a+(n-1)*b))
if enough(bot):
    print(bot)
    sys.exit(0)
top = ceil(max(H)/b)
mid = (top+bot)//2
while(top-bot>1):
    if enough(mid):
        top = mid
    else:
        bot = mid
    mid = (top+bot)//2

print(top)

Solution (Python):
import math

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


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


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

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

def judge(t):
    count = 0
    Bt = B * t
    for i in range(N):
        numerator = h[i] - Bt
        count += max(math.ceil(numerator / C), 0)
    return count <= t

left = 0
right = math.ceil(10**9 // B) + 1
mid = (left + right) // 2
while right - left > 1:
    if judge(mid):
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
print(right)

Solution (Python):
N, A, B = map(int,input().split())
h = [0 for i in range(N)]
for i in range(N):
	h[i] = int(input())
h = sorted(h)
import math




def enough(T):
	tmp = 0
	for i in range(N):
		if h[i] >= B*T:
			tmp += math.ceil((h[i]-B*T)/(A-B))
	return True if tmp <= T else False

MAX = 10**9
MIN = 0
MID = (MAX+MIN)//2
while MAX > MIN+1:
	if enough(MID) == True:
		MAX = MID
	else:
		MIN = MID
	MID = (MAX+MIN)//2
print(MAX)

Solution (Python):
import sys
from math import ceil
n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]

def enough(t):
    cnt = 0
    for h in H:
        
        rh = h - b * t
        if rh <= 0:
            continue
        cnt += rh//(a-b)
        if rh%(a-b) != 0:
            cnt += 1
    if cnt <= t:
        return True
    else:
        return False

bot = 0
top = ceil(max(H)/b)
mid = (top+bot)//2
while(top-bot>1):
    if enough(mid):
        top = mid
    else:
        bot = mid
    mid = (top+bot)//2

print(top)

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

N,A,B = map(int,input().split())
C = A-B
health = [int(input()) for i in range(N)]
health.sort()

def check(Bx):
	Ax = 0
	for h in health:
		if h > Bx*B:
			Ax += math.ceil((h-Bx*B)/C)
	return Ax <= Bx

low = 0
high = health[N-1]//B+1

while True:
	mid = (low+high)//2
	if check(mid):
		high = mid
	else:
		low = mid
	if high - low <= 1:
		break

print(high)

Solution (Python):


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


def enough(T):
    cnt = 0
    
    for i in range(N):
        hp = hN[i]
        
        hp -= B*T
        
        if hp > 0:
            cnt += (hp-1) // (A-B) +1
    
    if cnt <= T:
        return True
    else:
        return False












hi = 10 ** 9 + 1
low = 0
mid = 10 ** 9 // 2
while low+1 < hi:
    if enough(mid):
        hi = mid
    else:
        low = mid
    mid = (hi+low+1) // 2
print(mid)

Solution (Python):


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


def enough(T):
    cnt = 0
    
    for i in range(N):
        hp = hN[i]
        
        hp -= B*T
        
        if hp > 0:
            cnt += (hp-1) // (A-B) +1
    
    if cnt <= T:
        return True
    else:
        return False


hi = 10 ** 9
low = 0
while low+1 < hi:
    mid = (hi+low) // 2
    if enough(mid):
        hi = mid
    else:
        low = mid
print(hi)

Solution (Python):
N,A,B = map(int,input().split())
H=[int(input()) for i in range(N)]
C = A-B
def tao(k):
    num=0
    for h in H:
        t = h -B*k
        if t >0:
            num += t//C
            if t %C !=0:
                num +=1
    if num <= k:
        return True
    else:
        return False

mi =0
ma=10**9+1
while ma-mi>1:
    mid = (ma +mi)//2
    if tao(mid):
        ma=mid
    else:
        mi=mid
print(ma)

Solution (Python):
n,a,b = (int(i) for i in input().split())
h = [int(input()) for i in range(n)]
def dmg(x):
	num = 0
	for i in h:
		if i>b*x: num+=(i-b*x-1)//(a-b)+1
	return num<=x
hi,lo = 10**9+1,0
while hi-lo!=1:
	mid = (hi+lo)//2
	if dmg(mid): hi=mid
	else: lo=mid
print(hi)

Solution (Python):
import math
n, a, b=[int(i) for i in input().split()]
ab=a-b
t=[int(input()) for i in range(n)]
mx = sum([i//a +1 for i in t])
mi = 1

while mx - mi > 1:
  i = (mx + mi) // 2
    
  if sum([max(math.ceil((j- i * b) /ab),0) for j in t ]) <= i:
    mx = i
  else:
    mi = i
  
print(mx)

Solution (Python):
N,A,B=map(int,input().split())
H=[]
s=0
cnt_max=0

for i in range(N):
  h=int(input())
  s+=h
  cnt_max+=(h//A+1)
  H.append(h)

cnt_min=sum(H)//(B*N+(A-B)*N)
H.sort(reverse=True)
  
def check(n):
  res=n
  dmg=A-B
  dmg2=n*B
  for i in range(N):
    if H[i]>dmg2:
      if (H[i]-dmg2)%dmg==0:
        res-=((H[i]-dmg2)//dmg)
      else:
        res-=((H[i]-dmg2)//dmg+1)  
    if res<0:
      return False
  return True

while True:
  if cnt_min+1==cnt_max:
    if check(cnt_min):
      print(cnt_min)
      break
    else:
      print(cnt_max)
      break
  ans=(cnt_min+cnt_max)//2
  if check(ans):
    cnt_max=ans
  else:
    cnt_min=ans

Solution (Python):
N,A,B = map(int,input().split())
src = [int(input()) for i in range(N)]
src.sort(reverse=True)

def isok(n):
    if all(h <= n*B for h in src):
        return True
    m = 0
    for h in src:
        h -= n*B
        m += (h-1)//(A-B) + 1
        if m > n:
            return False
    return True

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

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

i = 10 ** 9
left, mid, right = 0, i // 2, i + 1

def attack(x):
    global n, a, b
    d = a - b
    remain = x
    for j in monsters:
        temp = j - b * x
        if temp > 0:
            remain -= (temp + d - 1) // d
    return remain >= 0

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

print(mid)

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

from math import ceil

def can_korosu(t):
    count = 0
    for h in H:
        count += ceil(max(0, h - t*B)/(A-B))
        if count > t:
            return False
    return True

lo = 0
hi = 10**9

p = (lo, hi)
for _ in range(50):
    mid = (hi + lo) // 2
    if can_korosu(mid):
        hi = mid
    else:
        lo = mid
    if p == (lo, hi):
        break
    p = (lo, hi)
print(hi)

Solution (Python):
import math

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

add_damage = A-B
left = 1
right = 10**9
ans = float('inf')

for i in range(int(math.log(10**9, 2)+1)):
    T = (left+right) // 2
    h = H.copy()
    h = list(map(lambda x: math.ceil(max(0, x-T*B) / add_damage), h))
    need = sum(h)
    
    if need <= T:
        right = T
        ans = min(ans, T)
    else:
        left = T

print(ans)

Solution (Python):
import math

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

add_damage = A-B
left = 1
right = 10**9
ans = float('inf')

for i in range(int(math.log(10**9, 2)+1)):
    T = (left+right) // 2
    h = H.copy()
    h = list(map(lambda x: max(0, x-T*B), h))
    h = list(map(lambda x: math.ceil(x / add_damage), h))
    need = sum(h)
    
    if need <= T:
        right = T
        ans = min(ans, T)
    else:
        left = T

print(int(ans))

Solution (Python):
N, A, B = map(int, input().split())
h = [int(input()) for i in range(N)]
Tmax=2*max(h)//B
def Tenabled(Tin):
    x = [h[i] for i in range(N)]
    for i in range(N):
        x[i] -= B*Tin
    S = 0
    for i in range(N):
        if x[i]>0:
            S += -((-x[i])//(A-B))
    if S<=Tin:
        return True
    else:
        return False


high=Tmax
low=0
t=(high+low)//2
while(low<=high):
    if Tenabled(t):
        high=t
    else:
        low=t+1
    t=(high+low)//2
    if Tenabled(t)==True and Tenabled(t-1)==False:
        break
print(t)

Solution (Python):
def d_Widespread(N, A, B, H):
    from math import ceil
    low = 0
    high = max(H) // B + 1  

    def enough(t):
        time = 0
        for h in H:
            if h > B * t:
                
                time += ceil((h - B * t) / (A - B))
        if time <= t:
            return True
        else:
            return False

    while high - low > 1:
        mid = (low + high) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
    return high

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

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

INF = int(1e9)
l, m, r = 0, INF//2, INF + 1

def calc(n):
    global N, A, B
    d = A - B
    remain = n
    for h in hs:
        tmp = h - B * n
        if tmp > 0:
            remain -= (tmp + d - 1) // d
    return remain >= 0

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

print(m)

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

high=max(h)/B+1
low=1

def enough(T):
	cnt=0
	for i in h:
		i-=T*B
		if i>0:
			if i%(A-B)==0:
				cnt+=i/(A-B)
			else:
				cnt+=i/(A-B)+1
	if cnt<=T:
		return True
	else:
		return False

ans=0
while low<=high:
	c= (low + high) / 2
	if enough(c):
		high=c-1
		ans=c
	else:
		low=c+1


print ans

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

high=max(h)
low=1

def enough(T):
	cnt=0
	for i in h:
		i-=T*B
		if i>0:
			if i%(A-B)==0:
				cnt+=i/(A-B)
			else:
				cnt+=i/(A-B)+1
	if cnt<=T:
		return True
	else:
		return False

ans=0
while low<=high:
	c= (low + high) / 2
	if enough(c):
		high=c-1
		ans=c
	else:
		low=c+1


print ans

Solution (Python):
import math
import sys
sys.setrecursionlimit(100000000)

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

def bsearch(begin, end):
  if begin == end:
    return begin
  else:
    if is_ok( (begin+end)//2):
      return bsearch(begin, (begin+end)//2)
    else:
      return bsearch( (begin+end)//2 + 1, end)

def is_ok(n):
  h_tmp = h.copy()
  cnt = 0
  cnt = sum([math.ceil((hp-B*n)/(A-B)) for hp in h_tmp if hp-B*n >= 0])
  return cnt <= n

print(bsearch(0, 1000000000))

Solution (Python):

"""
http://abc063.contest.atcoder.jp/tasks/arc075_b
TLE
"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline


def Cond(monsters, A, B, mid):
    t = [x - (B * mid) for x in monsters]
    t.sort(reverse=True)
    additional_damage = (A - B)

    total_count = 0
    for m in t:
        if m < 1:
            break
        total_count += ceil(m / additional_damage)

    if total_count <= mid:
        return True
    else:
        return False


def main(args):
    
    
    
    
    N, A, B = map(int, input().split())
    monsters = [int(input()) for _ in range(N)]

    total_count = 0
    if N == 1:
        total_count = ceil(monsters[0] / A)
    else:
        monsters.sort(reverse=True)
        lb = ceil(monsters[0] / A)
        ub = ceil(monsters[0] / B)
        
        

        for _ in range(30):
            mid = (lb + ub) // 2
            if Cond(monsters, A, B, mid):
                ub = mid
            else:
                lb = mid
        total_count = int(ub)

    print(total_count)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
import math

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


def judge(K):
    sums = 0
    for i in h:
        t = i-K*B
        if t > 0:
            sums += math.ceil(t*1.0/(A-B))
            if sums > K:
                return False;
    return True


high = int(1e9)
low = 0

while low < high:
    mid = int((high + low) / 2)
    if judge(mid):
        high = mid;
    else:
        low = mid+1;

print low

Solution (Python):
import math

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

def judge(K):
    sums = 0
    for i in h:
        t = i-K*B
        if t > 0:
            sums += math.ceil(t*1.0/(A-B))
            if sums > K:
                return False;
    return True

high = int(1e9)
low = 0

while high > low:
    mid = int((high + low) / 2)
    if judge(mid):
        high = mid;
    else:
        low = mid+1;

print low

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

import math

def enough(T):
    num = 0
    for hi in h:
        if hi - B * T <= 0:
            return True

        num += math.ceil((hi - B * T) / (A - B))
        if num > T:
            return False

    return True

h.sort(reverse=True)

iFrom = 1
iTo = math.ceil(h[0] / B)
while iFrom != iTo:
    iMid = iFrom + (iTo - iFrom) // 2

    if enough(iMid) == True:
        iTo = iMid
    else:
        iFrom = iMid + 1

print(iFrom)

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

C=A-B
sum,d=0,0
high = math.ceil(max(H)/B)
low = 0
while high > low:
    sum = 0
    mid = (high + low) //2
    for i in range(N):
        if H[i]-B*mid > 0:
            sum += math.ceil((H[i]-B*mid)/C)
    if sum <= mid:
        high = mid
    else:
        low = mid + 1

print(low)