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)]


def f(x):
    cnt = 0
    for e in h:
        cnt += max(0, ceil((e - b * x) / (a - b)))

    if cnt > x:
        return False

    return True


l = 0
r = ceil(max(h) / b)
while r - l > 1:
    mid = (l + r) // 2
    if f(mid):
        r = mid
    else:
        l = mid

print(r)

Solution (Python):
from math import ceil

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


def f(x):
    cnt = 0
    for e in h:
        cnt += max(0, ceil((e - b * x) / (a - b)))

    if cnt > x:
        return False

    return True


l = 0
r = 10 ** 9 + 1
while r - l > 1:
    mid = (l + r) // 2
    if f(mid):
        r = mid
    else:
        l = mid

print(r)

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

H=[]
for _ in range(N):
    H.append(int(input()))

ok=10**9+1
ng=0

while ok-ng>1:
    mid=(ok+ng)//2
    dmg=B*mid
    tgt=0
    for item in H:
        tgt+=-(-max(item-dmg,0)//(A-B))
    if tgt<=mid:
        ok=mid
    else:
        ng=mid

print(ok)

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

def hantei(now):
    ab=a-b
    nokori = sum(kiriage( max(0,hh-now*b) ,ab)//ab  for hh in h)
    return nokori<=now
def kiriage(x,c):
    if x%c==0:
        return x
    else:
        return (x//c+1) *c

ma = 10**9 +1
mi = 1

while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)

    if which:
        ma=now
        ans=now
    else:
        mi=now+1
print(ans)

Solution (Python):
from math import ceil
def check(x,hp):
    hp=[hh-(b*x) for hh in hp]
    cnt=0
    for p in hp:
        if p<=0:continue
        cnt+=ceil(p/(a-b))
    return cnt<=x

n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]
lo=0
hi=10**9
while hi-lo>1:
    mid=(hi+lo)//2
    if check(mid,h):
        hi=mid
    else:
        lo=mid
ans=hi


print(hi)

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B=MI()
    h=[0]*N
    for i in range(N):
        h[i]=I()
        
    def ch(X):
        
        temp=0
        for i in range(N):
            hp=h[i]-X*B
            if hp>0:
                temp+=(hp+A-B-1)//(A-B)
        if temp<=X:
            return True
        return False
    
    ng=0
    ok=10**9
    
    while abs(ok-ng)>1:
        x=(ok+ng)//2
        if ch(x):
            ok=x
        else:
            ng=x
    print(ok)
        

main()

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

def check(X):
  base = B * X
  counts = sum([max((h - base + dAB - 1)//dAB, 0) for h in Hn])
  return counts <= X
               
def min_binary_search(check, l=0, r=100000000000):
    while r - l > 1:
      mid = (l + r) // 2
      if check(mid):
        r = mid
      else:
        l = mid
    return r
print(min_binary_search(check))

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

    def is_ok(H, mid):
        H = [h - mid*B for h in H]
        need = 0
        for h in H:
            if h > 0:
                need += (h + (A - B) - 1)//(A - B)
        if need <= mid:
            return True
        else:
            return False

    def binary_search_meguru(H):
        ng = -1
        ok = 10**9 + 1
        while abs(ok - ng) > 1:
            mid = ng + (ok - ng) // 2  
            if is_ok(H, mid):
                ok = mid
            else:
                ng = mid
        return ok

    print(binary_search_meguru(H))


if __name__ == '__main__':
    main()

Solution (Python):
from math import ceil

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


def is_all_kill(C:int):
    cnt = 0
    for HP in h:
        
        tmp = ceil((HP-B*C)/(A-B))
        
        if tmp <= 0:
            break
        cnt += tmp
    return cnt <= C

ok = 10 ** 18
ng = 0
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_all_kill(mid):
        ok = mid
    else:
        ng = mid

print(ok)

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

def ok(x):
    tot = 0
    for i in range(n):
        if b*x >= H[i]:
            continue
        else:
            r = H[i] - b*x
            if r%(a-b) == 0:
                tot += r//(a-b)
            else:
                tot += r//(a-b)+1
    if tot <= x:
        return True
    else:
        return False

l = 0
r = 10**10
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Solution (Python):
import numpy as np

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


def C(X):
    """
    x回爆発して、全部消滅させれるとTrue
    """
    HP = H - X * B
    HP = HP[HP > 0]
    cnt = (HP + A - 1) // A
    return cnt.sum() <= X


l = -1
r = 10 ** 18
while r - l > 1:
    m = (r + l) // 2
    if C(m):
        r = m
    else:
        l = m

ans = r
print(ans)

Solution (Python):
def main():
    n, a, b = map(int, input().split())
    h = [int(input()) for _ in range(n)]
    low, high = 0, 1000000000000000000
    while low < high:
        mid = (low + high) // 2
        tmp = 0
        for _h in h:
            if _h > mid * b:
                tmp += (_h - mid * b + a - b - 1) // (a - b)
        if tmp > mid:
            low = mid + 1
        else:
            high = mid
    print(low)


if __name__ == '__main__':
    main()

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

max_t = - (- max(H) // b)

def clear_or_not(a, b, t, H):
    count_t = 0
    for i in range(len(H)):
        need_t = -(-(H[i] - b*t) //(a-b))
        if need_t <= 0:
            need_t = 0
        count_t += need_t
    if count_t <= t:
        return True
    else:
        return False
\
def bisect(low=1, high=max_t):
    while high-low > 1:
        mid = low + (high-low)//2
        if clear_or_not(a,b,mid,H):
            high = mid
        else:
            low = mid
    return high
ans = bisect()

print(ans)

Solution (Python):
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(x):
    k = b*x
    sm = 0
    for i in range(n):
        sm += max(0, (h[i]-k+c-1)//c)
    
    return (sm<=x)

n,a,b = inm()
h = []
for i in range(n):
    h.append(inn())
c = a-b
mn = 0
mx = (max(h)+b-1)//b
while mx>mn+1:
    mid = (mx+mn)//2
    if foo(mid):
        mx = mid
    else:
        mn = mid
print(mx)

Solution (Python):
import sys
import queue
import bisect

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007



def main_b1():
	n, a, b = IN()
	al = [int(input()) for _ in range(n)]
	if len(al)==1:
		return (al[0] + a -1)//a
	
	al.sort()
	max_value = al[-1]
	min_value = al[0]
	dd_queue = queue.PriorityQueue()
	for v in al:
		dd_queue.put((-v, v))
		
	cc=0
	dmage_diff = a-b
	while True:
		_, max_hp=dd_queue.get()
		if max_hp-(b*cc) <= 0:
			return cc
			
		_, second_max_hp = dd_queue.get()
		nb = ((max_hp-second_max_hp)+dmage_diff-1)//dmage_diff
		
		if max_hp <= nb * a:
			return (max_hp + a - 1)//a
		
		cc += nb
		next_hp=max_hp-dmage_diff*nb
		dd_queue.put((-next_hp, next_hp))
		dd_queue.put((-second_max_hp, second_max_hp))

def is_ok(sorted_list, c, a, b):
	ii=bisect.bisect_right(sorted_list,b*c)
	count=c
	diff=a-b
	for v in sorted_list[ii:]:
		nokori = v - c*b
		count -= (nokori+diff-1)//diff
		if count < 0:
			return False
	return True

def main():
	n, a, b = IN()
	al = [int(input()) for _ in range(n)]
	al.sort()
	
	ok = (al[-1]+b-1)//b
	ng = 0
	while ok-ng > 1:
		mm=(ok+ng)//2
		if is_ok(al, mm, a, b):
			ok = mm
		else:
			ng = mm
	return ok
		

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

N, A, B = map(int, readline().split())
A = A - B
H = np.array([int(readline()) for _ in range(N)], dtype=np.int64)


def C(T):
    h = H-B*T
    h = h[h > 0]
    bomb = (h + A - 1) // A
    return bomb.sum() <= T


left = 0
right = 10 ** 18
while right - left > 1:
    mid = (right + left) // 2
    if C(mid):
        right = mid
    else:
        left = mid

ans = right
print(ans)

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

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


def C(T):
    """
    T回爆発させて、魔物全滅できるか
    """
    damage = B * T
    cnt = 0
    for h in H:
        h -= damage
        if h <= 0:
            continue
        cnt += (h + (A - B) - 1) // (A - B)
        if cnt > T:
            return False
    return cnt <= T


left = 0
right = 10 ** 18
while right - left > 1:
    mid = (right + left) // 2
    if C(mid):
        right = mid
    else:
        left = mid

ans = right
print(ans)

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

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


def C(T):
    """
    T回爆発させて、魔物全滅できるか
    """
    damage = B * T
    cnt = 0
    for h in H:
        h -= damage
        if h <= 0:
            continue
        cnt += (h + (A - B) - 1) // (A - B)
    return cnt <= T


left = 0
right = 10 ** 18
while right - left > 1:
    mid = (right + left) // 2
    if C(mid):
        right = mid
    else:
        left = mid

ans = right
print(ans)

Solution (Python):
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
A -= B 
H = np.array([ir() for _ in range(N)])

def check(x):
    hp = H - B*x
    hp = hp[hp>0]
    cnt = ((hp + A - 1) // A).sum()
    return cnt <= x


left = 0 
right = 10 ** 9 
while right > left + 1:
    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 _ in range(n)]

import math
def ok(x):
    t = 0
    for i in range(n):
        r = h[i] - b*x
        if r < 0:
            continue
        else:
            t += math.ceil(r/(a-b))
    if t <= x:
        return True
    else:
        return False

l = 0
r = 10**14+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

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

import math
def ok(x):
    t = 0
    for i in range(n):
        r = h[i] - b*x
        if r < 0:
            continue
        else:
            t += math.ceil(r/(a-b))
    if t <= x:
        return True
    else:
        return False

l = 0
r = 10**14+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Solution (Python):
from math import ceil
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]
def enough(x):
  cnt=0
  for i in range(n):
    if h[i]-x*b<=0:
      continue
    cnt+=ceil((h[i]-x*b)/(a-b))
  if cnt<=x:
    return True
  else:
    return False
l=0
r=10**9
while r-l>0:
  mid=(r+l)//2
  if enough(mid):
    r=mid
  else:
    l=mid+1
print(r)

Solution (Python):

def check(x,hp):
    hp=[hh-(b*x) for hh in hp]
    explosion=0
    for hhh in hp:
        if hhh<=0:continue
        if hhh%(a-b)==0:
            explosion+=hhh//(a-b)
        else:
            explosion+=hhh//(a-b)+1
    return explosion<=x

n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]
lo=0
hi=10**9
while hi-lo>1:
    mid=(hi+lo)//2
    if check(mid,h):
        hi=mid
    else:
        lo=mid
print(lo+1)

Solution (Python):
import math
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
l = 0
r = math.ceil(max(H))
ans = 0
d = A-B
while(1):
    if l+1 == r:
        ans = r
        break
    else:
        m = (l+r) // 2
        count = 0
        for i in range(N):
            if (H[i] - m*B) > 0:
                count += math.ceil((H[i]-m*B) / d)
        if count <= m:
            r = m
        else:
            l = m
print(ans)

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

right = max(monsters) // b + 1
left = 0

while left+1 < right:
    bomb_count = (left+right) // 2
    base_damage = bomb_count * b

    center_count = 0
    for hp in monsters:
        if hp <= base_damage:
            continue

        remaining_hp = hp - base_damage
        need_center = (remaining_hp + a-b-1) // (a-b)
        center_count += need_center

    if center_count <= bomb_count:
        right = bomb_count
    else:
        left = bomb_count

print(right)

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

    def is_ok(x):
        y = 0  
        for i, h in enumerate(H):
            if h - x*B <= 0:
                continue
            le = 0
            ri = 10**9 + 1
            while ri - le > 1:
                mid = le + ((ri - le) // 2)
                if h - B*(max(x - mid, 0)) - A*mid <= 0:
                    ri = mid
                else:
                    le = mid
            y += ri
        if y <= x:  
            return True
        else:
            return False

    def binary_search_meguru():
        left = -1
        right = 10**9 + 1
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(mid):
                right = mid
            else:
                left = mid
        return right

    print(binary_search_meguru())


if __name__ == '__main__':
    main()

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

def f(n):
    cnt = 0
    flag = True
    for h in H:
        x = (h-B*n)//(A-B) + min((h-B*n)%(A-B), 1)
        cnt += max(0, x)
    if cnt <= n:
        return True
    else:
        return False
        
l = 0
r = 10**9
while r-l > 1:
    m = (r+l)//2
    if f(m):
        r = m
    else:
        l = m
        
if f(l):
    print(l)
else:
    print(r)

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

ok=10**9
ng=0

while abs(ok-ng)>1:
 mid=(ok+ng)//2

 l=[i-(mid*b) for i in h]
 cnt=0
 for j in l:
  if j<=0:
   continue
  cnt+=(j+a-b-1)//(a-b)

 if cnt<=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)]

h_sum=sum(h)

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

 l=[max(i-(mid*b),0) for i in h]
 cnt=0
 for j in l:




  if j%(a-b)==0:
   cnt+=j//(a-b)
  else:
   cnt+=j//(a-b)+1

 if cnt<=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)]

h_sum=sum(h)

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

 l=[i-(mid*b) for i in h]
 cnt=0
 for j in l:

  if j<=0:
   continue

  if j%(a-b)==0:
   cnt+=j//(a-b)
  else:
   cnt+=j//(a-b)+1

 if cnt<=mid:
  ok=mid
 else:
  ng=mid

print(ok)

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

Th = 2*max(h)//B
Tl = 0
while Tl+1<Th:
  t = (Th+Tl)//2
  d = []
  for i in range(N):
    c = h[i]
    d += [c-B*t]
  for i in range(N):
    c = d[i]
    if c<=0:
      continue
    t -= c//(A-B) if c%(A-B)==0 else c//(A-B)+1
    if t<0:
      Tl = (Th+Tl)//2
      break
  else:
    Th = (Th+Tl)//2
print(Th)

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

Th = 2*max(h)//B
Tl = 0
while Tl+1<Th:
  t = (Th+Tl)//2
  d = []
  for i in range(N):
    c = h[i]
    d += [c-B*t]
  for i in range(N):
    c = d[i]
    if c<=0:
      continue
    t -= ceil(c/(A-B))
    if t<0:
      Tl = (Th+Tl)//2
      break
  else:
    Th = (Th+Tl)//2
print(Th)

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

Th = 2*max(h)//B
Tl = 0
while Tl+1<Th:
  t = (Th+Tl)//2
  d = []
  for i in range(N):
    c = h[i]
    d += [c-B*t]
  for i in range(N):
    c = d[i]
    if c<=0:
      continue
    t -= ceil(c/(A-B))
    if t<0:
      Tl = (Th+Tl)//2
      break
  else:
    Th = (Th+Tl)//2
print(Th)

Solution (Python):
def binary_search(h, left, right, a,b):
    d = a-b
    while left + 1 < right:
        k = (left+right)//2
        cost = 0
        for i in h:
            tmp = i - k * b
            if tmp <= 0:
                continue
            cost += (tmp + d - 1) // d
        
        if cost > k:
            left = k
        else:
            right = k
    return right


n,a,b = map(int,input().split())
h = []
cnt = 0
for _ in range(n):
    i = int(input())
    h.append(i)
    cnt += (i+a-1)//a
print(binary_search(h, -1, cnt+1,a,b))

Solution (Python):
from math import ceil
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort(reverse=True)
ok,ng=10**9,0
while ok-ng>1:
  mid=(ok+ng)//2
  damage=mid*b
  addition=mid
  flag=True
  for i in range(n):
    if h[i]<=damage:
      continue
    else:
      if addition>=ceil((h[i]-damage)/(a-b)):
        addition-=ceil((h[i]-damage)/(a-b))
      else:
        addition-=ceil((h[i]-damage)/(a-b))
        flag=False
        break
  if flag:
    ok=mid
  else:
    ng=mid
print(ok)

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

while mx-mn>1:
    md = (mx+mn)//2
    h2 = [h[i]-md*b for i in range(n)]
    
    tmp = 0
    for i in range(n):
        if h2[i]>0:
            tmp += (h2[i]+(a-b)-1)//(a-b)
    if tmp<=md:
        mx = md
    else:
        mn = md

print(mx)

Solution (Python):
u = 10**9
d = 0
N,A,B = map(int,input().split())
s = A - B
H = []
import math
for i in range(N):
    h = int(input())
    H.append(h)
for i in range(30):
    x = (u+d)//2
    a = 0
    for j in range(N):
        h = H[j]
        h -= B*x
        if h > 0:
            a += math.ceil(h/s)
    if a > x:
        d = x
    else:
        u = x
print(u)

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

Solution (Python):
import math
N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]
low = sum(H)//((N-1)*B+A)-1
high = max(H)//B+1
while high-low>1:
    mid = (high+low)//2
    cnt = 0
    for i in range(N):
        cnt += math.ceil(max(H[i]-mid*B,0)/(A-B))
    if cnt<=mid:
        high = mid
    else:
        low = mid
print(high)

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

def is_ok(K):
    return sum(max(0, -(-(h - B * K) // (A - B))) for h in H) <= K

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

print(ok)

Solution (Python):
def bisect(f, ok, err):
    while abs(ok - err) > 1:
        m = (ok + err) // 2
        if f(m):
            ok = m
        else:
            err = m
    return ok

def main():
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    A -= B
    def f(n):
        return sum((max(0,h-B*n)+A-1)//A for h in H) <= n
    print(bisect(f, 10**9+1, 0))

if __name__ == "__main__":
    main()

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

l = 0
r = 10 ** 18

while r - l > 1:
  m = (r + l) // 2
  li = [h - b * m for h in H]
  cnt = sum([(i - 1) // (a - b) + 1 if i > 0 else 0 for i in li])
  if cnt <= m:
    r = m
  else:
    l = m
print(r)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
h = [INT() for _ in range(N)]

ng = 0
ok = ceil(max(h)/B)

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


while ng+1 != ok:
    m = (ok+ng)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

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

N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort(reverse=True)
left = 0
right = 10**10
while left < right:
    mid = (left + right) // 2
    remaining = mid
    ok = True
    for health in h:
        x = (health-B*mid+A-B-1) // (A-B)
        remaining -= x
        if remaining < 0:
            ok = False
            break
    if ok:
        right = mid
    else:
        left = mid + 1
print(right)

Solution (Python):
import sys
input = sys.stdin.readline
n,a,b = map(int,input().split())
hls = [int(input()) for i in range(n)]
l = 0
r = sum(hls)
while l<r:
  x = (l+r)//2
  cnt = 0
  for hp in hls:
    if hp-x*b>0:
      cnt += (hp-x*b+(a-b)-1)//(a-b)
  if cnt>x:
    l = x+1
  elif cnt<x:
    r = x
  else:
    ans = x
    break
if l == r:
  ans = l
print(ans)

Solution (Python):
n,a,b = map(int,input().split())
hls = [int(input()) for i in range(n)]
l = 0
r = 10**15
while l<r:
  x = (l+r)//2
  cnt = 0
  for hp in hls:
    if hp-x*b>0:
      cnt += (hp-x*b+(a-b)-1)//(a-b)
  if cnt>x:
    l = x+1
  elif cnt<x:
    r = x
  else:
    ans = x
    break
if l == r:
  ans = l
print(ans)

Solution (Python):
n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]
c = a - b
def is_can(x):
  s = 0
  d = b*x
  for h in H:
    s += max(0, -(-(h-d) // c))
  if s <= x:
    return True
  return False

ng = 0
ok = -(-max(H)//b)
while ok - ng > 1:
  m = (ok+ng)//2
  if is_can(m):
    ok = m
  else:
    ng = m
print(ok)

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

start=0
end=10**9
import math

for _ in range(30):
    sub=0
    judge=(start+end)/2
    for some in lists:
        sub+=max(0,math.ceil((some-b*math.floor(judge))/(a-b)))

    if sub<judge:
        start=start
        end=judge
    elif sub>=judge:
        start=judge
        end=end
print(math.floor(start)+1)

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)//2
    if explode(k):
        r=k
    else:
        l=k

print(l if explode(l) else r)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            
            ok = mid
        else:
            
            ng = mid
    return ok

def check(m):
    b = B * m
    cnt = 0
    for h in H:
        
        h -= b
        if h > 0:
            
            cnt += ceil(h, A)
    
    return cnt <= m

N, A, B = MAP()
H = LIST(N)

A -= B


res = bisearch_min(0, 10**9, check)
print(res)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            
            ok = mid
        else:
            
            ng = mid
    return ok

def check(m):
    
    b = B * m
    H2 = [h-b for h in H]
    
    cnt = 0
    for h in H2:
        if h > 0:
            cnt += ceil(h, A)
    
    return cnt <= m

N, A, B = MAP()
H = LIST(N)

A -= B


res = bisearch_min(0, 10**9, check)
print(res)

Solution (Python):
import math

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

H = [int(input()) for _ in range(N)]
H.sort(reverse=True)


hi = math.ceil(H[0] / B)
lo = 1


while hi - lo > 1:
    can_defeat_all_enemies = True
    mid = (hi+lo) // 2
    cnt_extra_attack = 0

    for i in range(N):
        if H[i] > mid * B:
            cnt_extra_attack += math.ceil((H[i] - mid * B) / (A - B))
        
        else:
            break
    
    
    if cnt_extra_attack <= mid:
        hi = mid
    else:
        lo = mid

print(hi)

Solution (Python):
import math

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

H = [int(input()) for _ in range(N)]
H.sort(reverse=True)


hi = H[0]
lo = 1


while hi - lo > 1:
    can_defeat_all_enemies = True
    mid = (hi+lo) // 2
    cnt_extra_attack = 0

    for i in range(N):
        if H[i] > mid * B:
            cnt_extra_attack += math.ceil((H[i] - mid * B) / (A - B))
        
        else:
            break
    
    
    if cnt_extra_attack <= mid:
        hi = mid
    else:
        lo = mid

print(hi)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    def ok(m):
        an=m
        for h in hh:
            d=h-b*m
            if d>0:
                an-=(d+a-b-1)//(a-b)
            if an<0:return False
        return True

    n,a,b=MI()
    hh=[int(input()) for _ in range(n)]
    mx=max(hh)
    l=mx//a-1
    r=mx//b+2
    while l+1<r:
        m=(l+r)//2
        if ok(m):r=m
        else:l=m
    print(r)

main()

Solution (Python):

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

high = int(1e10)
low = 0
mid = 0
ad_attack = B - A

while low < high:
    big_magic = 0
    mid = (high + low) // 2
    
    for i in range(N):
        big_magic += max((demon_health[i] - B * mid + (A - B - 1)) // (A - B), 0)
        
    if big_magic > mid:
        
        low = mid + 1
    else:
        high = mid
    

print(low)

Solution (Python):
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, input().rstrip('\n').split()))
    h = [int(input().rstrip('\n')) for _ in range(n)]
    cor_v = 10 ** 16
    inc_v = -1
    while cor_v - inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        
        for i in range(n):
            hp = h[i] - bin_v * b
            if hp > 0:
                cost += (hp + (a - b) - 1) // (a - b)
        
        if cost <= bin_v:
            cor_v = bin_v
        else:
            inc_v = bin_v
    print(cor_v)


if __name__ == '__main__':
    solve()