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):
def check(M):
    global A,B,Data
    plus = 0
    for d in Data:
        left = d - B*M 
        if left > 0:
            q,mod = divmod(left,A-B)
            plus += q
            if mod > 0:
                plus += 1
    return plus <= M

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

min1 = 0
max1 = 10**10

while max1 - min1 > 1:
    mid = (min1 + max1) // 2
    b = check(mid)
    if b == True:
        max1 = mid
    else:
        min1 = mid

print(max1)

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

D = A - B

L = -1
R = 10 ** 9

while L + 1 < R:
  M = (L + R) // 2
  
  cnt = 0
  for h in H:
    rest = h - M * B
    if rest > 0:
      cnt += - (- rest // D)
  if M >= cnt:
    R = M
  else:
    L = M
print(R)

Solution (Python):
import sys
import numpy as np

n, a, b = map(int, sys.stdin.readline().split())
h = np.array(sys.stdin.read().split(), dtype=np.int64)
r = a - b

def can_vanish_all(c):
    res = np.copy(h)
    res = np.maximum(res - b * c, 0)
    res = (res + r - 1) // r
    return np.sum(res) <= c

def main():
    lo = 0 
    hi = 10**9+1 
    while lo + 1 < hi:
        cnt = (lo + hi) // 2
        if can_vanish_all(cnt):
            hi = cnt
        else:
            lo = cnt
    
    return hi

if __name__ == '__main__':
    ans = main()
    print(ans)

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

ub = 10**9
lb = 0
while True:
    if ub == lb:
        break
    target = (ub + lb) // 2
    need = 0
    for h in hl:
        rest = h - target * b
        need += max(math.ceil(rest / (a-b)), 0)
    if need <= target:
        ub = target
    else:
        lb = target + 1
print(lb)

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

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

def check(K):
  s = 0
  D = K*B
  for h in H: s += max(0, (h-D+C-1)//C)
  return s<=K

max_NG = 0
min_OK = 10**10
while min_OK - max_NG > 1:
  tgt = (max_NG+min_OK)//2
  if check(tgt):
    min_OK = tgt
  else:
    max_NG = tgt

print(min_OK)

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

OK = max(H)//B+1
NG = 0

ans = OK
while OK-NG > 1:
    mid = (OK+NG)//2  
    cnt = 0

    for h in H:
        if h > mid*B:
            cnt += math.ceil((h-mid*B)/(A-B))

    if cnt <= mid:
        OK = mid
    else:
        NG = mid

print(OK)

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))



N,A,B = II()
h = Line(N,1)

left = -1
right = 10**9

while abs(right-left)>1:
    mid = (right+left)//2
    counter = 0
    for i in range(N):
        if h[i]>mid*B:
            counter += math.ceil((h[i]-mid*B)/(A-B))
    if counter<=mid:
        right = mid
    else:
        left = mid

print(right)

Solution (Python):
import sys
import numpy as np
read = sys.stdin.read

N, A, B, *h = map(int, read().split())

h = np.array(h, np.int64)


l = 0
r = max(h) // B + 2
a = A - B
while l + 1 < r:
    mid = (l + r) // 2
    w = B * mid
    tmp = h - w
    tmp = tmp[tmp > 0]
    tmp = tmp // a + np.minimum(tmp % a, 1)
    if tmp.sum() <= mid:
        r = mid
    else:
        l = mid

print(r)

Solution (Python):
import sys
import numpy as np
read = sys.stdin.read

N, A, B, *h = map(int, read().split())

h = np.array(h, np.int64)


l = 0
r = (max(h) // B) * N
a = A - B
while l + 1 < r:
    mid = (l + r) // 2
    w = B * mid
    tmp = h - w
    tmp = tmp[tmp > 0]
    tmp = tmp // a + np.minimum(tmp % a, 1)
    if tmp.sum() <= mid:
        r = mid
    else:
        l = mid

print(r)

Solution (Python):
_,a,b,*H=map(int,open(0).read().split())
l,r=0,10**9
while r-l>1:
	m=(l+r)//2
	if-sum(min(0,(h-m*b)//(b-a))for h in H)>m:l=m
	else:r=m
print(r)

Solution (Python):
N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
C = A - B
l, r = 0, 1<<30
while r - l > 1:
    m = (l + r) // 2
    if sum([max((h - B * m + C - 1) // C, 0) for h in H]) <= m:
        r = m
    else:
        l = m
print(r)

Solution (Python):
N,A,B=map(int,input().split())
Aadd=A-B
H=[0]*N
for i in range(N):
  H[i]=int(input())
MAXV=max(H)//B+(max(H)%B>0)
ng=-1
ok=MAXV+1

def isOK(n):
  Anum=0
  Bdamage=n*B
  for i in range(len(H)):
    rest=H[i]-Bdamage
    if rest>0:
      Anum+=rest//Aadd+(rest%Aadd>0)
  if Anum<=n:
    return True
  return False
        
while abs(ok-ng)>1:
  mid=abs(ok+ng)//2
  if isOK(mid):
    ok=mid
  else:
    ng=mid
    
print(ok)

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

import math

def C(d):
    sum = 0
    for i in range(n):
        sum += math.ceil(max(h[i] - b * d, 0) / (a - b))
    return sum <= d

lb = -1
ub = 10 ** 9 + 1
while (ub - lb) > 1:
    mid = (lb + ub) // 2
    if C(mid):
        ub = mid
    else:
        lb = mid
print(ub)

Solution (Python):
import math
n, a, b = map(int, input().split())
h = []
spread = b
attack = a - b
count = 0
for i in range(n):
    h.append(int(input()))
h.sort()
h.reverse()
def binary_search(left, right):
    if right - left <= 1:
        return right
    middle = (right + left)//2
    count = 0
    for i in range(n):
        if h[i] - (middle * spread) <= 0:
            break
        else:
            count += math.ceil((h[i] - (middle * spread)) / attack)
    if count > middle:
        return binary_search(middle, right)
    elif count < middle:
        return binary_search(left, middle)
    else:
        return middle
print(binary_search(0,10**10))

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

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

Solution (Python):
import heapq
from math import ceil

def check(ls,mid,a,b):
    count = 0
    for now in ls:
        now -= mid*b
        count += ceil(max(now,0)/(a-b))
    if count<=mid:
        return True
    else:
        return False

def main():
    n,a,b = map(int,input().split())
    h = [int(input()) for _ in range(n)]
    can_l,can_r = 0,10**9
    while 1:
        if can_r==can_l:
            print(can_r)
            exit()
        elif abs(can_r-can_l)==1:
            if check(h,max(can_r,can_l),a,b):
                print(max(can_l,can_r))
                exit()
            else:
                print(min(can_l,can_r))
                exit()
        mid = ceil((can_l+can_r)/2)
        if check(h,mid,a,b):
            can_r = mid
        else:
            can_l = mid
        
if __name__ == "__main__":
    main()

Solution (Python):
n,a,b=map(int,input().split())
H=[int(input()) for _ in range(n)]
r=10**10
l=0
while r-l>1:
    k=(l+r)//2
    if sum( max(0,(h-k*b-1)//(a-b)+1) for h in H)>k:
        l=k
    else:
        r=k

print(r)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, a, b = LI()
H = IR(n)
ok = 10 ** 9
ng = 0
while ok > ng + 1:
    mid = (ok + ng) // 2
    ret = 0
    for h in H:
        remain = h - b * mid
        if remain > 0:
            ret += remain // (a - b) + bool(remain % (a - b))
    if ret <= mid:
        ok = mid
    else:
        ng = mid


print(ok)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

def bisection(l,r,f,left=True,discrete=True):
    eps=1 if discrete else 10**-12
    if((not left)^f(r)): return r if left else r+1
    elif(left^f(l)): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if not discrete else l if left else r

from math import ceil

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

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

    print(bisection(0,max(H),check,left=False))
resolve()

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


def f(n, H, A, B): 
    c = 0
    for i in range(len(H)):
        t = H[i]
        t -= B*n
        if t > 0:
            c += t//(A-B) + min(1, t%(A-B))
    if c > n:
        return False
    else:
        return True
    
    
def g(u, l, H, A, B): 
    if u-l < 2:
        if f(l, H, A, B):
            return l
        else:
            return u
    m = (u+l)//2
    if f(m, H, A, B):
        return g(m, l, H, A, B)
    else:
        return g(u, m, H, A, B)
    
    
ans = g(10**9, 1, H, A, B)
print(ans)

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

import math
def enough(n):
    rest = [h - B * n * 1.0 for h in H]
    m = sum([ math.ceil(r/(A-B)) for r in rest if r > 0])
    return m <= n

l, r = 0, 10**9

while r - l > 1:
    mid = (l + r) // 2
    if enough(mid):
        r = mid

    else:
        l = mid

    

print(r)

Solution (Python):

def updiv(a,b):

    if a % b == 0:
        return a // b
    else:
        return a // b + 1

def able(n):

    nt = 0
    for i in range(N):
        if h[i] - B*n <= 0:
            continue
        nt += updiv(h[i] - B*n , A-B)
        

    if nt <= n:
        return True
    else:
        return False

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

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

l = 0
r = max(h)
lf = able(l)
rf = able(r)

while r - l != 1:

    m = (l + r) // 2
    mf = able(m)

    if not mf:
        l = m
        lf = mf
    else:
        r = m
        rf = mf

print (r)

Solution (Python):
import math

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


def check(n):
    d = n * B
    t = 0
    for h in H:
        if h <= d:
            continue
        t += (h - d + (A - B - 1)) // (A - B)
    return t <= n


lo, hi = 0, 10 ** 9

while lo < hi:
    mi = (lo + hi) // 2
    if check(mi):
        hi = mi
    else:
        lo = mi + 1

print(hi)

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

def hantei(p):
    global a,b
    tp = p
    fa = a - b
    for sh in h:
        sh -= b * p
        if sh > 0:
            tp -= (sh+fa-1) // fa
            if tp < 0:
                return False
    return True


def nibun(l,r):
    if r == l:
        return l
    f = (l+r)//2
    if hantei(f):
        return nibun(l,f)
    else:
        return nibun(f+1,r)

print(nibun(1,10**9))

Solution (Python):
def examD():
    N, A, B = LI()
    h = [I() for _ in range(N)]
    upper = max(h); lower = 1; cur = (upper+lower)//2
    while (True):
        curne = 0
        for i in h:
            if i-cur*B>0:
                curne  += (i-cur*B-1)//(A-B) +1
        if upper - lower >= 2:
            if curne > cur:
                
                lower = cur
                cur = (cur + upper) // 2
            else:
                upper = cur
                cur = (cur + lower) // 2
        else:
            if curne > cur:
                
                cur = upper
                curne = 0
                for i in h:
                    if i - cur * B > 0:
                        curne += (i - cur * B - 1) // (A - B) + 1
                if curne > cur:
                    break
            else:
                cur = lower
                curne = 0
                for i in h:
                    if i - cur * B > 0:
                        curne += (i - cur * B - 1) // (A - B) + 1
                if curne < cur:
                    ans = lower
                    break
            ans = upper
            break
    print(ans)



import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()

Solution (Python):
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
h = []
for _ in range(N):
  h.append(int(input()))
h.sort()
def explosive(x):
  c = 0
  for i in range(N):
    if h[i] > x * B:
      c += -(-(h[i] - x * B) // (A - B))
  if c <= x: return True
  else: return False
ng = 0
ok = 10 ** 9
m = 0
while ok - ng > 1:
  m = (ng + ok) // 2
  
  if explosive(m):
    ok = m
  else:
    ng = m
print(ok)

Solution (Python):
import math

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


def ok(n):
    d = n * B
    t = 0
    for h in H:
        if h <= d:
            continue
        t += math.ceil((h - d) / (A - B))
        
    return t <= n


lo, hi = 0, 10 ** 9

while lo < hi:
    mi = (lo + hi) // 2
    if ok(mi):
        hi = mi
    else:
        lo = mi + 1

print(hi)

Solution (Python):
n,a,b=map(int,input().split())
c=a-b
h=[int(input()) for i in range(n)]
low=1
high=10**9+1
while high-low>0:
    k=(high+low)//2
    count=0
    for u in h:
        u-=b*k
        if u>0:
            if u%c==0:
                count+=u//c
            else:
                count+=u//c+1
    if high-low==1:
        if count<=k:
            print(k)
            break
        else:
            print(k+1)
            break
    else:
        if count<=k:
            high=k
        else:
            low=k

Solution (Python):
def turn_check(inlist,p,q,x):
    s = q*x
    t = p-q
    return sum([ (max(i-s,0)+t-1)//t for i in inlist ]) <= x

n, a, b = [ int(v) for v in input().split() ]
h_list = [ int(input()) for i in range(n) ]
ok, ng = 10**9, 0
while ok-ng > 1:
    mid = (ok+ng)//2
    if turn_check(h_list,a,b,mid):
        ok = mid
    else:
        ng = mid
print(ok)

Solution (Python):
def turn_check(inlist,p,q,x):
    s = q*x
    t = p-q
    return sum([ (max(i-s,0)+t-1)//t for i in inlist ]) <= x

n, a, b = [ int(v) for v in input().split() ]
h_list = [ int(input()) for i in range(n) ]
ok, ng = 10**9, 0
while ok-ng > 1:
    mid = (ok+ng)//2
    if turn_check(h_list,a,b,mid):
        ok = mid
    else:
        ng = mid
print(ok)

Solution (Python):
n,a,b=map(int,input().split())
h=[]
for i in range(n):
    q=int(input())
    h.append(q)
left=0
right=max(h)+1
def en(t):
    cnt=0
    for i in range(n):
        if h[i]-b*t>0 and (h[i]-b*t)%(a-b)!=0:
            cnt+=((h[i]-b*t)//((a-b))+1)
        if h[i]-b*t>0 and (h[i]-b*t)%(a-b)==0:
            cnt+=((h[i]-b*t)//(a-b))
    if cnt<=t:
        return  True
    return  False
while left+1<right:
    tmp=(left+right)//2
    if en(tmp):
        right=tmp
    else:
        left=tmp
print(right)

Solution (Python):

import sys
from math import ceil

def solve(N: int, A: int, B: int, h: "List[int]"):
    INF = 10000000000
    
    def f(K: int):
        c = 0
        for i in range(N):
            c += ceil(max(0, h[i] - B*K)/(A-B))

        if c <= K:
            return True
        else:
            return False


    def binary_search(ok: int, ng: int):
        while ok-ng > 1:
            mid = (ok+ng)//2
            if f(mid):
                ok = mid
            else:
                ng = mid
        return ok

    
        
    
    
    
    
    
    

    

    print(binary_search(INF, 0))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    h = [int(next(tokens)) for _ in range(N)]  
    solve(N, A, B, h)

if __name__ == '__main__':
    main()

Solution (Python):

import sys
from math import ceil

def solve(N: int, A: int, B: int, h: "List[int]"):
    INF = 10000000000
    
    def f(K: int):
        c = 0
        for i in range(N):
            c += ceil(max(0, h[i] - B*K)/(A-B))

        if c <= K:
            return True
        else:
            return False


    def b(ok: int, ng: int):
        
        while ok-ng > 1:
            mid = (ok+ng)//2
            
            if f(mid):
                ok = mid
            else:
                ng = mid

        return ok

    print(b(INF, 0))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    h = [int(next(tokens)) for _ in range(N)]  
    solve(N, A, B, h)

if __name__ == '__main__':
    main()

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 ** 20
    inc_v = -1
    while cor_v - inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        
        for v in h:
            if v > bin_v * b:
                cost += (v - bin_v * b + (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()

Solution (Python):
from math import ceil
from bisect import bisect

n, a, b = map(int, input().split())
raw_hs = [int(input()) for _ in range(n)]
hs = sorted(raw_hs, reverse=True)
diff = a - b

c_min = 0
c_max = int(10e9)

while c_max - c_min > 1:
	c = (c_min + c_max) // 2
	tmp_hs = [h - c * b for h in hs]
	rem = sum([ceil(h / diff) for h in tmp_hs if h > 0])
	if rem > c:
		c_min = c
	else:
		c_max = c

print(c_max)

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

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

while hi-lo > 1:
    mi = (hi+lo)//2
    rest = 0
    for i in range(n):
        rest += max(0,-(-(H[i]-b*mi)//(a-b)))
    if rest <= mi:
        hi = mi
    else:
        lo = mi
        
print(hi)

Solution (Python):
import math

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


def chk(k):
    a_cnt = 0
    for h in H:
        tmp = h - B * k
        if tmp > 0:
            a_cnt += math.ceil(tmp / (A - B))
    return k >= a_cnt


def find(l, r):
    if l > r: return l
    m = (l + r) // 2
    if chk(m):
        r = m - 1
    else:
        l = m + 1
    return find(l, r)


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

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)]
    ok = 10 ** 9
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        d1 = b * mid
        d2 = a - b
        cnt = 0
        for v in h:
            cnt += max((v - d1 + d2 - 1) // d2, 0)
        if cnt <= mid:
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == '__main__':
    solve()

Solution (Python):

import sys
from math import ceil
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n,a,b=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
ok=inf
left=1
right=10**9+10
while left<right:
    mid=(left+right)//2
    tmp=0
    for hi in h:
        tmp+=max(0,ceil((hi-mid*b)/(a-b)))
    if tmp>mid:
        left = mid+1
    else:
        right=mid
        ok=min(ok,mid)
print(ok)

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

def can_kill(count):
    ness = 0
    for hp in h:
        ness += max(-(-(hp - B * count) // (A - B)), 0)
    if ness <= count:
        return True
    return False
    
while right - left > 1:
    middle = left + (right - left) // 2
    if can_kill(middle):
        right = middle
    else:
        left = middle

print(right)

Solution (Python):
from math import ceil 
n,a,b=map(int,input().split())
l=[int(input()) for i in range(n)]
def check(x):
    c=0
    l1=[i-b*x for i in l]
    for i in l1: 
         if i<=0:
             continue 
         c+=ceil((i)/(a-b))
    return c<=x
lo=0 
ans=-1 
hi=10**9+4 
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1
    else:
        lo=mi+1 
print(ans)

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

def C(x):
    Y = [0] * N
    for i in range(N):
        Y[i] = X[i] - x * B
    
    cnt = 0
    for i in range(N):
        if Y[i] > 0:
            cnt += (Y[i] + A - B - 1) // (A - B)
    return cnt <= x

ng = 0; ok = 10**18
while ok - ng > 1:
    mid = (ng + ok) >> 1
    if C(mid): ok = mid
    else: ng = mid

print(ok)

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

def check(t):
    l=[]
    for i in h:
        i-=t*B
        if i > 0:
            l.append(i)
    if len(l) != 0:
        while t>=0:
            i=l.pop()
            t-=-(-i//(A-B))
            if (len(l)==0) and (t>=0):
                return True
        return False
    else:
        return True

min=0
max=hmax
while max != min + 1:
    j=(max-min)//2+min
    if check(j) == True:
        max = j
    else:
        min = j
print(max)

Solution (Python):
import sys
I = lambda:int(sys.stdin.readline())
LI = lambda:[int(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]

N,A,B = LI()
H = IR(N)

def isOK(c):
    cnt = 0
    for enc in H:
        if enc - B*c > 0:
            cnt += ((enc - B*c)+(A-B)-1)//(A-B)
            if cnt > c:
                return False
    return True

OK = (max(H)+B-1)//B
NG = 0

while(OK-NG>1):
    mid = (OK+NG)//2
    if isOK(mid):
        OK = mid
    else:
        NG = mid

print(OK)

Solution (Python):
import sys
I = lambda:int(sys.stdin.readline())
LI = lambda:[int(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]

def check(a,b,h,c):
    cnt = 0
    for enc in h:
        if enc - b*c > 0:
            cnt += ((enc - b*c)+(a-b)-1)//(a-b)
            if cnt > c:
                return False
    return True


N,A,B = LI()
H = IR(N)

OK = (max(H)+B-1)//B
NG = 0

while(OK-NG>1):
    mid = (OK+NG)//2
    if check(A,B,H,mid):
        OK = mid
    else:
        NG = mid

print(OK)

Solution (Python):
import math
n, a, b = map(int, input().split())
list_enemy = [int(input()) for _ in range(n)]
list_enemy.sort(reverse=True)

diff_dam = a - b
min_a = math.ceil(list_enemy[-1] / a)
max_a = math.ceil(list_enemy[0] / b)
while max_a - min_a > 1:
  mid_a = min_a + (max_a - min_a) // 2
  count = 0
  for one_enemy in list_enemy:
    rest_h = one_enemy - (b * mid_a)
    if rest_h > 0:
      count += math.ceil(rest_h / diff_dam)
    else:
      break
  if count <= mid_a:
    max_a = mid_a
  else:
    min_a = mid_a
print(max_a)

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)

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

def calc(x):
  bomb = 0
  for h in H:
    if h > B*x:
      bomb += ((h-B*x)-1)//(A-B) +1
  return (x >= bomb)

def check(a,b):
  mid = (a+b)//2
  if a == mid:
    return b
  if calc(mid):
    return check(a,mid)
  else:
    return check(mid,b)

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

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

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

    def binary_search_meguru(Arr,N,A,B):
        left = -1
        right = 10**9 + 1
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(Arr,mid,N,A,B): right = mid
            else: left = mid
        return right
    
    print(binary_search_meguru(h,N,A,B))

if __name__ == '__main__':
    main()

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

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

    def binary_search_meguru(Arr,N,A,B):
        left = -1
        right = 10**10 + 1
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(Arr,mid,N,A,B): right = mid
            else: left = mid
        return right
    
    print(binary_search_meguru(h,N,A,B))

if __name__ == '__main__':
    main()

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

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

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

def check(T):
    t = 0
    for h in H:
        h -= B*T
        if h > 0:
            t += math.ceil(h/(A-B))
    return T >= t

def main():
    lb = ub = 0
    for h in H:
        ub += h//B + 1

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

    print(ub)

if __name__ == '__main__':
    main()

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7



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


def solve(bomb):
    count = 0
    for i in range(N):
        remain = H[i] - (B*bomb)
        
        if remain > 0:
            additional_damage = (A-B)
            c = -(-remain // additional_damage)
            count += c

    if count <= bomb:
        return True
    else:
        return False



def meguru(left, right):
    while abs(left - right) > 1:
        mid = (left + right) // 2;

        if (solve(mid)):
            left = mid
        else:
            right = mid;

    return left



print(meguru(max(H), 0))

Solution (Python):
import math

N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]
INF = 10**9
cnt = 0

def check(K):
  tmp = 0
  for i in range(N):
    rem = H[i] - B * K
    if rem > 0:
      tmp += math.floor((rem + (A - B - 1)) / (A - B))
  return tmp <= K

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

print(binary_search(INF,0))

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


def check(k):
    return sum([(x - k * b + a - b - 1) // (a - b)
                for x in ls if x - k * b > 0]) <= k


m = max(ls)
lo = (m + a - 1) // a
hi = (m + b - 1) // b + 1
mi = (hi + lo) // 2
while hi > lo:
    mi = (hi + lo) // 2
    if check(mi):
        hi = mi
    else:
        lo = mi + 1
print(lo)

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


def check(k):
    return sum([(x - k * b + a - b - 1) // (a - b)
                for x in ls if x - k * b > 0]) <= k


m = max(ls)
lo = (m + a - 1) // a
hi = (m + b - 1) // b + 1
mi = (hi + lo) // 2
while hi > lo + 1:
    mi = (hi + lo) // 2
    if check(mi):
        hi = mi
    else:
        lo = mi
if check(lo):
    print(lo)
else:
    print(hi)

Solution (Python):
n, a, b = map(int, input().split())
ls = [int(input()) for _ in range(n)]
m = max(ls)
lo = (m + a - 1) // a
hi = (m + b - 1) // b + 1
mi = (hi + lo) // 2
while hi > lo + 1:
    mi = (hi + lo) // 2
    if sum([(x - mi * b + a - b - 1) // (a - b)
            for x in ls if x - mi * b > 0]) <= mi:
        hi = mi
    else:
        lo = mi
if sum([(x - lo * b + a - b - 1) // (a - b)
        for x in ls if x - lo * b > 0]) <= lo:
    print(lo)
else:
    print(hi)