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 main():
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    left = 1
    right = max(H)
    while right - left > 1:
        t = (right + left) // 2
        c = 0
        for h in H:
            x = h - B * t
            if 0 >= x:
                continue
            c += x // (A - B)
            if x % (A - B):
                c += 1
        if c > t:
            left = t
        else:
            right = t
    print(right)


main()

Solution (Python):



import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

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

def binarysearch(): 
    def isOK(y): 
        res = 0
        for hi in h:
            hi -= b*y
            if hi <0: continue
            res += (hi+a-b-1)//(a-b)
        return res <= y
        
    ng = 0; ok = 10**9

    while(abs(ok-ng) > 1):
        mid = (ok + ng)//2
        if isOK(mid): ok = mid
        else: ng = mid
    return ok

print(binarysearch())

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


def check(n):

    c = 0
    for i in range(N):
        a = H[i] - n*B
        if a > 0:
            c += (a//(A-B)) + 1

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


l,h = 0,10**20
for _ in range(200):
    m = ((l+h)*0.5)
    if check(m):
        h = m
    else:
        l = m
import math
print(math.ceil(m))

Solution (Python):
n,a,b = map(int,input().split())
h = [int(input()) for _ in range(n)]
d = a-b
l = 0
r = 10**10+1
ans = r


def check(num):
    global h
    global d
    global b
    cnt = 0
    for i in h:
        if i>b*num:
            cnt+= (i-b*num+d-1)//d
    return cnt<=num


while r>=l:
    mid = (r+l)//2
    if check(mid):
        r = mid-1
        ans = min(ans,mid)
    else:
        l = mid+1
print(ans)

Solution (Python):
import math

def ok_check(half, data, num, a, b):
    kari = 0
    for i in range(num):
        nokori = data[i] - half * b
        if nokori > 0:
            kari += math.ceil(nokori / (a - b))
    if kari > half:
        return 0
    else:
        return 1

def check(left, right, data, num, a, b):
    if left == right - 1:
        print(right)
        return
    half = (left + right) // 2
    if ok_check(half, data, num, a, b):
        check(left, half, data, num, a, b)
    else:
        check(half, right, data, num, a, b)

def main():
    num, a, b = map(int, input().split())
    data = [int(input()) for i in range(num)]

    left = 0
    right = max(data) // b + 1
    check(left, right, data, num, a, b)

if __name__ == '__main__':
    main()

Solution (Python):
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def judge(x):
  res = np.ceil((hp - B*x)/(A-B))
  cnt = res[res > 0].sum()
  if cnt <= x:
    return True
  else:
    return False


def nibutan(n):
  left = 0
  right = n
  while left+1 != right:
    middle = (left+right)//2
    if judge(middle):
      right = middle
    else:
      left = middle
  return right

N,A,B = IL()
hp = np.array([I() for i in range(N)])
hp.sort()
n = hp[-1]//B+1

ans = nibutan(n)

print(ans)

Solution (Python):
import math

def hersCode(N):
  ng = -1
  ok = N
  while ok -  ng > 1:
    mid = (ok + ng) // 2
    if judge(mid):
      ok = mid
    else:
      ng = mid
  return ok

def judge(x):
  cnt = 0
  for i in h:
    cnt += max(0, math.ceil((i - x * B) / (A - B)))
  return cnt <= x


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

print(hersCode(10 ** 9))

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

def test(n):
    x = H - n*B
    x[x<0] = 0
    return np.ceil(x/(A-B)).sum() <= n

left = 0
right = 10**9

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

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

def attack(n):
    s = 0
    for h in H:
        h -= B*n
        if h > 0:
            s += ceil(h/(A-B))
    return s <= n

l = 0
r = 0
for h in H:
    r = max(ceil(h/B),r)

while l != r-1:
    mid = (l+r)//2
    if attack(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 attack(n):
    s = 0
    for h in H:
        h -= B*n
        if h > 0:
            s += ceil(h/(A-B))
    return s <= n

l = 0
r = 0
for h in H:
    r = max(ceil(h/B),r)

while l != r-1:
    mid = (l+r)//2
    if attack(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 attack(n):
    s = 0
    for h in H:
        h -= B*n
        if h > 0:
            s += ceil(h/(A-B))
    return s <= n

l = 0
r = 0
for h in H:
    r = max(ceil(h/B),r)

for _ in range(30):
    mid = (l+r)//2
    if attack(mid):
        r = mid
    else:
        l = mid

print(r)

Solution (Python):
import math
N, A, B = map(int, input().split())
H =[int(input()) for _ in range(N)]
H.sort(reverse = True)
s = 0
l = H[0]//B + 1
while l - s > 1:
    cnt = 0
    mid =(s+l) // 2
    x = mid*B
    for h in H:
        if h > x:
            cnt += math.ceil((h-x)/(A-B))
        else:
            break
    if cnt > mid:
        s = mid
    else:
        l = mid
print(l)

Solution (Python):
import sys
input=sys.stdin.readline
n,a,b=map(int,input().split())
H=[int(input()) for i in range(n)]
H.sort(reverse=True)
h=10**9
l=1
def check(t,a,b):
    c=b*t
    for i in H:
        if(i-c<=0):
            return True
        else:
            t+=(c-i)//(a-b)
            if(t<0):
                return False
    return True
while h!=l:
    t=(h+l)//2
    if(check(t,a,b)):
        h=t
    else:
        l=t+1
print(h)

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


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


if __name__ == "__main__":
    main()

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: int, B: int, h: "List[int]"):
    def can(n, A, B, a):
        tmp = 0
        base = B * n
        diff = A - B
        for v in a:
            rest = v - base
            if rest > 0:
                tmp += (rest - 1) // diff + 1
        if tmp <= n:
            return True
        return False
    h.sort(reverse=True)
    mx = h[0]
    l = 0
    r = (mx - 1) // B + 1
    while r - l > 1:
        m = (r + l) // 2
        if can(m, A, B, h):
            r = m
        else:
            l = m
    
    ret = r
    print(ret)
    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 math
def bsearch_int(init_ng, init_ok, cond):
    ng = init_ng
    ok = init_ok
    while(abs(ok - ng) > 1):
        mid = math.floor(abs(ok + ng)/2)
        if cond(mid):
            ok = mid
        else:
            ng = mid
    return ok

def condition(cnt, N, A, B, hs):
    basedmg = B*cnt
    diff = A - B
    diffcnt = 0
    for h in hs:
        if h < basedmg:
            break
        else:
            diffcnt += math.ceil((h-basedmg)/diff)
    if diffcnt > cnt:
        return False
    else:
        return True

import functools
def resolve():
    N, A, B = list(map(int, input().split(" ")))
    hs = [int(input()) for i in range(N)]
    hs.sort(reverse=True)
    print(bsearch_int(0, math.ceil(hs[0]/B), functools.partial(condition, N=N, A=A, B=B, hs=hs)))


if __name__ == '__main__':
    resolve()

Solution (Python):
from math import ceil
N,A,B=map(int,input().split())
H=[]
d=A-B
for i in range(N):
    h=int(input())
    H.append(h)
b=ceil(max(H)/B)
a=0
while(a!=b):
    m=a+(b-a)//2
    t=0
    for h in H:
        t+=ceil(max(h-B*m,0)/d)
    if t<=m:
        b=m
    else:
        a=m+1
print(a)

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


def bisect_left_callable(fn, x, lo, hi):
    """
    lo から hi-1 のうち、fn の結果が x 以上となる、最も左の値
    bisect.bisect_left と同じ
    https://docs.python.org/ja/3/library/bisect.html
    :param callable fn:
    :param x:
    :param int lo: 最小値
    :param int hi: 最大値 + 1
    :return: lo <= ret <= hi
    """
    while lo < hi:
        mid = (lo + hi) // 2
        if fn(mid) < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


N, A, B = list(map(int, sys.stdin.readline().split()))
H = [int(sys.stdin.readline()) for _ in range(N)]
H = np.array(H)


def can_clear(count):
    
    
    center_counts = np.maximum(0, np.ceil((H - count * B) / (A - B)))
    return int(center_counts.sum() <= count)


cnt = bisect_left_callable(can_clear, 1, lo=1, hi=10 ** 10)
print(cnt)

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

def check(T):
    t = 0
    for i in range(N):
        if lst[i] > B * T:
            t += max((lst[i]-B*T + (A-B-1))//(A-B), 0)
        else:
            pass
    return t <= T

la = -1
ua = 10 ** 9
ans = 10 ** 9
while ua - la > 1:
    mid = (la + ua)//2
    if check(mid):
        ans = min(ans, mid)
        ua = mid
    else:
        la = mid
print (ans)

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

def check(T):
    t = 0
    for i in range(N):
        if lst[i] > B * T:
            t += max((lst[i]-B*T + (A-B-1))//(A-B), 0)
        else:
            pass
    return t <= T

la = -1
ua = 10 ** 9
ans = 10 ** 9
while ua - la > 1:
    mid = (la + ua)//2
    if check(mid):
        ans = min(ans, mid)
        ua = mid
    else:
        la = mid
print (ans)

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

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

MAX=max(H)//B+1
MIN=min(H)//A

SA=A-B

while MAX!=MIN:
    
    x=(MAX+MIN)//2
    REST=[]

    for h in H:
        if h-B*x>0:
            REST.append(h-B*x)

    ANS=0
    
    for r in REST:
        ANS+=-(-r//SA)

        if ANS>x:
            MIN=x+1
            break
    else:
        MAX=x

print(MAX)

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

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

L.sort()

ans = (L[-1] // B) + 1

def f(n):
    c = n
    for v in L:
        if v > n * B:
            v -= n * B
            t = v // (A - B)
            if v % (A - B) != 0:
                t += 1
            c -= t
    return c >= 0

first = 1
for _ in range(40):
    t = (first + ans) // 2
    if f(t):
        ans = t
    else:
        first = t

print(ans)

Solution (Python):
import math

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

left, right = 0, math.ceil(max(h)/B)
AB = A - B

while left+1 < right:
    mid = math.ceil((left + right) / 2)

    h_ = list(filter(lambda x: x > 0, [n - mid*B for n in h]))

    if sum([math.ceil(n / AB) for n in h_]) <= mid:
        right = mid
    else:
        left = mid

print(right)

Solution (Python):
import numpy as np

N, A, B = list(map(int, input().split()))
h = np.array([int(input()) for i in range(N)], dtype='int64')

left, right = 0, np.ceil(np.max(h)/B)

while left+1 < right:
    mid = np.ceil((left + right) / 2)
    x = h - mid*B
    x[x<0] = 0
    x = np.ceil(x / (A - B))

    if np.sum(x) <= mid:
        right = mid
    else:
        left = mid

print(int(right))

Solution (Python):

import math
n,a,b = map(int, input().split())

m = [0] * n
for i in range(n):
  m[i] = int(input())
  

m.sort()


def enough(m,a,b,T):
  cnt = 0
  for hp in m:
    if hp > b*T:
      cnt += int(math.ceil((hp - b*T)/(a-b)))
      
  return True if  cnt <= T else False

r = 10**10

l = 0
mid = 0

while r - l > 1:
  mid = (r+l)//2
  if enough(m,a,b,mid) == True:
    r = mid
    
  else:
    l = mid
    

print(r)

Solution (Python):
from numpy import*
def main():
  t,*h=open(0)
  _,a,b=int32(t.split())
  h=int32(h)
  i,j=0,2**30
  while~i+j:
    k=(j+i)//2
    t=(b*k-h)//(a-b)
    if-k>sum(t[t<0]):i=k
    else:j=k
  print(j)
main()

Solution (Python):
from numpy import*
def main():
  _,a,b,*h=map(int,open(0).read().split())
  h=int32(h)
  i,j=0,2**30
  while~i+j:
    k=(j+i)//2
    t=(b*k-h)//(a-b)
    if-k>sum(t[t<0]):i=k
    else:j=k
  print(j)
main()

Solution (Python):
def main():
  from numpy import int32,sum
  _,a,b,*h=map(int,open(0).read().split())
  h=int32(h)
  i,j=0,2**30
  while~i+j:
    k=(j+i)//2
    t=(b*k-h)//(a-b)
    if-k>sum(t[t<0]):i=k
    else:j=k
  print(j)
main()

Solution (Python):
from numpy import*
t,*h=open(0)
_,a,b=int32(t.split())
h=int32(h)
i,j=0,2**30
while~i+j:
  k=(j+i)//2
  t=(b*k-h)//(a-b)
  if-k>sum(t[t<0]):i=k
  else:j=k
print(j)

Solution (Python):
from numpy import*
t,*h=open(0)
_,a,b=int32(t.split())
i,j=0,2**30
while~i+j:
 k=(j+i)//2;t=(b*k-int32(h))//(a-b)
 if-k>sum(t[t<0]):i=k
 else:j=k
print(j)

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

Solution (Python):
from numpy import*
from copy import deepcopy

def main():
    n,a,b,*h=map(int,open(0).read().split())
    h=array(h)
 
    ok=-1
    ng=max(h)+10
    
    def judge(t):
        H=deepcopy(h)
        H-=b*t
        H=H[H>0]
        if sum((H-1)//(a-b)+1)<=t:
            return 1
        else:
            return 0
    
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if judge(mid):
            ng=mid
        else:
            ok=mid
    l=ok+1
    print(l)
    
if __name__ == '__main__':
    main()

Solution (Python):

from numpy import*





from collections import* 
from fractions import gcd
from functools import* 
from itertools import* 
from operator import mul,itemgetter
from bisect import* 
from heapq import* 
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)


def main():
    n,a,b,*h=map(int,open(0).read().split())
    h=array(h)

    ok=-1
    ng=max(h)+10
    
    def judge(t):
        H=deepcopy(h)
        H-=b*t
        H=H[H>0]
        if sum((H-1)//(a-b)+1)<=t:
            return 1
        else:
            return 0
    
    while abs(ok-ng)>1:
        mid=(ok+ng)//2

        if judge(mid):
            ng=mid
        else:
            ok=mid
    l=ok+1
    print(l)

if __name__ == '__main__':
    main()

Solution (Python):
n,a,b=map(int,input().split())
a-=b
h=[]
s=0
for i in range(n):
    x=int(input())
    h.append(x)
    s+=x
h.sort(reverse=True)
x,z,f=0,2**(len(bin((s+b-1)//b))-2),0
while x!=z:
    if z-x==1:f=1
    y=(x+z)//2
    j=0
    for k in h:
        if k<y*b:break
        j+=(k-y*b+a-1)//a
    if f==0:
        if j>y:x=y
        else:z=y
    if f==1:
        if j>y:print(z)
        else:print(x)  
        break

Solution (Python):











import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    from heapq import heappop, heappush, heappushpop
    from math import floor,ceil,sqrt,factorial
    """O(max(h)*log(n))なので無理
    N, A, B = MI()
    H = []
    
    for _ in range(N):
        h=I()
        heappush(H, -h)
    C = A - B
    
    for i in range(1, -H[0] // B + 2):
        heappushpop(H, H[0] + C)
        print(H[0],i,i*B)
        if - H[0] <= i * B:
            print(i)
            break
            """
    
    N, A, B = MI()
    H = LIN(N)
    C=A-B

    def is_ok(n):
        cnt = 0
        for h in H:
            cnt+=max(0,ceil((h-n*B)/C))
        return cnt <= n
        
    ok = 10 ** 9 // B + 1
    ng=0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    print(ok)

        
        
        

if __name__ == '__main__':
    main()

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

def can_eliminate(n): 
  H_ = [((h-B*n)+A-B-1)//(A-B) for h in H if h>B*n]
  if sum(H_)<=n:
    
    return True
  else:
    
    return False
    
def binary_search(l,r): 
  
  if r==l+1:
    if can_eliminate(l):
      return l
    else:
      return r
  
  c = (l+r)//2
  if can_eliminate(c):
    return binary_search(l,c)
  else:
    return binary_search(c,r)
  
print(binary_search(1, (sum(H)+2*B+1)//B))

Solution (Python):
def enough(T, N, A, B, H):
	d = A - B
	cnt = 0
	for i in H:
		cnt += max(0, (i - T * B - 1)//d + 1)
	if cnt <= T:
		return 1
	else:
		return 0


N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
M = (max(H) - 1)//B + 1
hi_z, hi_p = M, 1
low_z, low_p = 0, 0
t = M
while hi_z - low_z > 1:
	mid_z = (hi_z + low_z)//2
	mid_p = enough(mid_z, N, A, B, H)
	if mid_p == 1:
		hi_z, hi_p = mid_z, mid_p
	else:
		low_z, low_p = mid_z, mid_p
print(hi_z)

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

def isOK(p):
  lic = sum([ (max(0,it-p*(B))+(A-B-1))//(A-B) for it in li ])
  if lic <= p:
    return True
  else:
    return False

low = 0
high = 10000000000
for i in range(1000000000):
  key = (low+high)//2
  flag = isOK(key)
  if ( flag ):
    high = key
  else:
    low = key
  if ( low + 1 >= high ):
    break
print ( high )

Solution (Python):
import numpy as np

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

def test(n):
  
  x = h - n*B
  x[x<0] = 0
  return np.ceil(x/(A-B)).sum() <= n


left = 0 
right = 10**9 

while right - left > 1:
  mid = (left + right)>>1
  if test(mid):
    right = mid
  else:
    left = mid

answer = right
print(answer)

Solution (Python):
from math import ceil


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



def bis(p, ok, ng):
    mid = (ok + ng) // 2
    return (
        ok if abs(ok - ng) == 1 else
        bis(p, mid, ng) if p(mid) else
        bis(p, ok, mid)
    )


ans = bis(
    lambda k: sum(max(0, ceil((x - k * B) / (A - B))) for x in h) <= k,
    10**10,
    0
)


print(ans)

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

Solution (Python):
import sys
import math
input = sys.stdin.readline
N, A, B = map(int, input().split())
h_list = []
for _ in range(N):
    h_list.append(int(input()))

def compare(k):
    cnt = 0
    for h in h_list:
        tmp_h = h - k*B
        x = max(math.ceil(tmp_h/(A-B)),0)
        cnt += x
        if cnt > k:
            return False
    return True
def solve():
    ng = 0
    ok = math.ceil(max(h_list) / B)
    while abs(ok-ng) > 1:
        mid = (ng + ok) // 2
        res = compare(mid)
        if (res):
            ok = mid
        else:
            ng = mid
    return ok
print(solve())

Solution (Python):

n,a,b = map(int,input().split())
h=[int(input()) for i in range(n)]
def solve(t):
    cur = 0
    for i in range(n):
        cur +=max(-(-(h[i]-b*t)//(a-b)),0)
    return cur <= t

def binary_search(l,r):
    while abs(r-l) >1:
        mid = (l+r)//2
        if solve(mid):
            r = mid
        else:
            l = mid
    return r
print(binary_search(0,10**9+1))

Solution (Python):


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

def check(t):
    c=0
    for i in range(n):
        c+=1+(max(0,h[i]-b*t)-1)//(a-b)
    return t>=c

l=0
r=3+max(h)//b
while r-l>1:
    mid=(r-l)//2+l
    if check(mid):
        r=mid
    else:
        l=mid
ans=l
if check(r):
    ans=r
print(ans)

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

h = []
for i in range(n):
    h.append(int(input()))
st,ed = 0,10**9+1
while st<ed-1:
    mid = (st+ed)//2
    
    tmp = 0
    for i in range(n):
        x = h[i]-mid*b
        if x>0:
            tmp+=(x//(a-b))+(x%(a-b)>0)
    if tmp<=mid:
        ed = mid
    else:
        st = mid
print(ed)

Solution (Python):
from functools import reduce
import math

def is_ok(t,h,A,B):
    cnt = 0 
    for hp in h:
        cnt += max(0,math.ceil((hp-B*t)/(A-B)))
    if t >= cnt:
        return True
    else:
        return False

def main():
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    INF = float("inf")
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N,A,B = (int(_) for _ in input().split())
    h = []
    max_h = 0
    for i in range(N):
        h.append(int(input()))
        max_h = max(h[i],max_h)        
    ng = -1
    ok = math.ceil(max_h/B) 

    
    while (abs(ok-ng)>1):
        mid = (ok + ng) //2
        if is_ok(mid,h,A,B):
            ok = mid
        else:
            ng = mid
    print(ok)
    
if __name__ == '__main__':
    main()

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

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

def judge(k):
    cnt = 0
    for h in H:
        cnt += -(-(max(h-k*B,0))//(A-B))
    if cnt <= k:
        return True
    return False

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

ans = biserch(max(H),-1,judge)
print(ans)

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

def is_eliminatable(num):
    avr_d = num * b
    count = 0
    for item in h:
        hp = item - avr_d
        if hp > 0:
            count += math.ceil(hp / alpha_d)
        if count > num:
            return False
    return True

r = 10**15
l = -1 
while (r-l > 1):
    mid = l + (r - l) // 2
    if is_eliminatable(mid):
        r = mid
    else:
        l = mid
print(r)

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

d = A-B

def judge(k):
    cnt = 0
    remain = [max(h-k*B,0) for h in H]
    for r in remain:
        cnt += -(-r // d)
    if cnt <= k:
        return True
    else:
        return False

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

ans = biserch(10**9,-1,judge)
print(ans)

Solution (Python):
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
    
def f(x):
    s = sum([- (- max(0, h - x * B) // (A - B)) for h in H])
    if s <= x:
        return True
    else:
        return False
    
l = 0
r = 10 ** 9 + 7
while l < r:
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m + 1
    
        
print(r)

Solution (Python):
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
    
def f(x):
    s = sum([- (- max(0, h - x * B) // (A - B)) for h in H])
    if s <= x:
        return True
    else:
        return False
    
l = 0
r = 10 ** 9 + 7
while r - l > 1:
    m = (l + r) // 2
    if f(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 f(x):
    s = sum([math.ceil(max(0, h - x * B) / (A - B)) for h in H])
    if s <= x:
        return True
    else:
        return False
    
l = 0
r = 10 ** 9 + 7
while r - l > 1:
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m
    
        
print(r)

Solution (Python):
import sys

def is_enough(H, A, B, T):
    cnt = 0
    diff = A - B
    base = B * T
    for h in H:
        if h <= base:
            continue

        cnt += (h - base + diff - 1) // diff
        if cnt > T:
            return False

    return True


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

    R = (max(H) + B - 1) // B
    L = (min(H) + A - 1) // A
    while R != L:
        c = (R + L) // 2
        if is_enough(H,  A, B, c):
            R = c
        else:
            L = c + 1

    return L


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

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

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

Solution (Python):
from math import ceil


def widespread(N: int, A: int, B: int, H: list)->int:
    def killable_by(T: int)->bool:
        return sum(max(0, ceil((h-B*T)/(A-B))) for h in H) <= T

    l, r = 0, 10**9
    while r - l > 1:
        m = (l + r) // 2
        if killable_by(m):
            r = m
        else:
            l = m

    return r


if __name__ == "__main__":
    N = 0
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    ans = widespread(N, A, B, H)
    print(ans)

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

Solution (Python):
import sys
def p(*a):
  s=" ".join(map(str,a))
  
  sys.stderr.write(s+"\n")

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

import math
C=A-B
TMax=math.ceil(max(H)/B)
TMin=1
p(A,B,C,TMax,TMin)

def canWipe(t):
  x=0
  for h in H:
    x+=max(0,math.ceil((h-B*t)/C))
    if x>t: break
  return (t>=x)

t=TMax
ans=t
while TMax!=TMin:
  t=(TMax+TMin)//2
  if canWipe(t):
    ans=t
    TMax=t
  else:
    TMin=t+1
print(ans)

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

h = [int(input()) for i in range(n)]
diff = a-b
def solve(num):
  kaisu = 0
  for i in range(n):
    if -((-(h[i]-num*b))//diff) > 0:
      kaisu += -((-(h[i]-num*b))//diff)
  if kaisu <= num:
    return True
  else:
    return False
    
ng = 0
ok = 1000000001

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

print(ok)

Solution (Python):
def d_widespread(N, A, B, H):
    from math import ceil
    lower_limit = 0
    upper_limit = max(H) // B + 1  

    def can_defeat(t):
        
        
        time_defeat_all = sum([ceil((h - B * t) / (A - B)) for h in H if h > B * t])
        return time_defeat_all <= t

    while upper_limit - lower_limit > 1:
        mid = (lower_limit + upper_limit) // 2
        if can_defeat(mid):
            upper_limit = mid
        else:
            lower_limit = mid
    return upper_limit

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())
H = [int(input()) for _ in range(N)]

mh = max(H)
x = mh//A
y = -(-mh//B)

def judge(cnt):
    d = A-B
    tmp = 0
    for h in H:
        nh = max(h-B*cnt,0)
        tmp += -(-nh//d)
    if cnt >= tmp:
        return True
    else:
        return False

def biserch(left=x,right=y):
    while right-left>1:
        middle = (left+right) // 2
        if judge(middle) is True:
            right = middle
        else:
            left = middle
    return right

rec = biserch()
print(rec)

Solution (Python):
n, a, b = map(int, input().split())
hlist = [int(input()) for _ in range(n)]
maxn = (max(hlist) + b - 1) // b

def enough(t):
  c = 0
  for h in hlist:
    if h - b * t > 0:
      c += (h - b * t + a - b - 1) // (a - b)
  return c <= t

l, r = 0, maxn
while l != r:
  mid = (l + r) // 2
  if enough(mid):
    r = mid
  else:
    l = mid + 1
print(l)