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):
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys
ceil=math.ceil
n,a,b = ma()
H = []
for i in range(n):
    H.append(ni())
H.sort()
def isok(x):
    bs = b*x
    d=a-b
    cnt=0
    for h in H:
        if h>bs:
            cnt+=math.ceil((h-bs)/d)
    return cnt<=x

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

Solution (Python):
def binary_search_int(ok, ng, test):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid):
            ok = mid
        else:
            ng = mid
    return ok



import sys
input = sys.stdin.readline

def test(x):
    cnt = 0
    for h in H:
        if h-x*B>0:
            cnt += ceil((h-x*B)/(A-B))
    return cnt <= x

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

res = binary_search_int(10**9,-1,test)
print(res)

Solution (Python):



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

def check(k):
    ret = 0
    for hi in h:
        if hi - k * b> 0:
            ret += ((hi - k * b)+(a-b-1)) // (a-b)
    return k >= ret

ok = 10**9
ng = -1

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

print(ok)

Solution (Python):
from copy import copy
N,A,B = map(int,input().split())
h_ls = [int(input()) for _ in range(N)]
add = A-B

def check(times):
    monster_ls = copy(h_ls)
    need = 0
    for i in range(N):
        monster_ls[i] -= B*times
        if monster_ls[i] > 0:
            need += -(-monster_ls[i]//add)
            
    if need > times:
        
        return False
    else:
        
        return True
    
def return_min_ind_whose_value_not_less_than(upper):
    r = upper
    l = -1
    while True:
        next_ind = (r+l) // 2
        if check(next_ind):
            r = next_ind
        else:
            l = next_ind
        if r - l == 1:
            return r

upper = 10**9+1
print(return_min_ind_whose_value_not_less_than(upper))

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,a,b,*h = map(int,read().split())

ng = 0
ok = 10**9

d = a-b

def check(mid,d,b):
    res = 0
    for hi in h:
        hi -= b*mid
        res += max(0,(hi+d-1)//d)
    
    return res <= mid        

while ok-ng > 1:
    mid = (ok+ng)//2
    if check(mid,d,b):
        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.sort(reverse=True)
tmp = 0


ans = 0

low = 0

high = 10**9

while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    
    
    num = 0
    
    for i in range(n):
        num += max(0,(h[i]-mid*b+(a-b-1))//(a-b))
    
    
    
    if num <= mid:
        high = mid
    else:
        low = mid
        
print(high)

Solution (Python):
A,B,C = list(map(int,input().split()))
import sys
listA = " ".join(sys.stdin.readlines()).replace("\n","").split()
listA = list(map(int,listA))
m_n=0
N = 0
B = B-C
max_n=10**10
while max_n-m_n>1:
    N = 0
    mid=(m_n+max_n) //2
    for i in listA:
        N += (max(i-C*mid,0)-1) // B+1
    if N <= mid:
        max_n = mid
    else:
        m_n  = mid
print(max_n)

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

monster = []
for _ in range(n):
    monster.append(int(input()))

def check(monster, a, b, n):
    temp = []
    for i in range(len(monster)):
        if monster[i] > b * n:
            temp.append(monster[i] - b * n)
    ans = 0
    for t in temp:
        ans += ceil(t / (a - b))
    if ans <= n:
        return True
    return False


l = 0
r = 10 ** 9
ans = float('inf')
while l <= r:
    mid = (l + r) // 2
    if check(monster, a, b, mid):
        ans = min(ans, mid)
        r = mid - 1
    else:
        l = mid + 1
print(ans)

Solution (Python):
from bisect import bisect_left as bl,bisect_right as br
n,a,b=map(int,input().split())
l=[int(input()) for i in range(n)]
a=a-b
l.sort()
def enough(t):
    global l,a,b,n
    ans=0
    for i in range(br(l,b*t),n):
        ans-=(-l[i]+b*t)//a
    return ans<=t
ub,lb=-(-l[-1]//b),-1
while ub-lb>1:
    if enough((ub+lb)//2):ub=(ub+lb)//2
    else:lb=(ub+lb)//2
print(ub)

Solution (Python):
from bisect import bisect_left as bl,bisect_right as br
n,a,b=map(int,input().split())
l=[]
a=a-b
for _ in range(n):
    l.append(int(input()))
l.sort()
def enough(t):
    global l,a,b,n
    ans=0
    for i in range(br(l,b*t),n):
        ans-=(-l[i]+b*t)//a
    return ans<=t
ub,lb=-(-l[-1]//b),-1
while ub-lb>1:
    if enough((ub+lb)//2):ub=(ub+lb)//2
    else:lb=(ub+lb)//2
print(ub)

Solution (Python):
N,A,B = map(int,input().split())
H =[]
for i in range(N):
  H.append(int(input()))
H.sort(reverse=True)
  
def judge(k):
  mas=k
  S=B*k
  for i in range(N):
    l = H[i]-S
    if l>0:
      mas-=l//(A-B)+min(1,l%(A-B))
    if mas<0:
      return False
  return True
  
def binary(max):
  l=0
  r=max
  while l<=r:
    m=(l+r)//2
    j = judge(m)
    if j==True:
      r=m-1
      ans=m
    else:
      l=m+1
  return ans
print(binary(H[0]//B+1))

Solution (Python):

n,a,b = map(int,input().split())
a -= b
h = []
for _ in range(n):
  h.append(int(input()))
now = 0
scale = 2**31
while scale != 0:
  tmp = now + scale
  cnt = 0
  for x in h:
    y = x - tmp * b
    if y > 0:
      cnt += (y-1) // a + 1
  if cnt > tmp:
    now = tmp
  
  scale //= 2
print(now+1)

Solution (Python):
import itertools
import math





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


OK = 10 ** 10 
NG = 0  

while OK - NG > 1:
    target = (OK + NG) // 2 
    s = 0 
    for h in hs:
        temp = (h- target * B)/(A-B)
        temp = math.ceil(temp)
        s += max(temp,0)
    if target >= s:
        OK = target
    else:
        NG = target
print(OK)

Solution (Python):
def examC():
    N = I()
    S = [I() for _ in range(N)]
    S1 = []
    for s in S:
        if s%10==0:
            continue
        S1.append(s)
    if S1==[]:
        print(0)
        return
    S1.sort()
    ans = sum(S)
    if ans%10==0:
        ans -= S1[0]
    print(ans)
    return

def examD():
    N, A, B = LI()
    H = [I() for _ in range(N)]
    H.sort()
    l = 0; r = (H[-1]-1)//B + 1
    while(r-l>1):
        now = (l+r)//2
        cur = 0
        for i in H:
            if i-now*B>0:
                cur += ((i-now*B-1)//(A-B) +1)
        if cur>now:
            l = now
        else:
            r = now
    ans = r
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examD()

"""

"""

Solution (Python):
import sys

def check(h, a, b, x):
    tot = 0
    for _ in h:
        if _ - x * b <= 0:
            continue
        tot +=  (_ - x * b + a - b - 1) // (a - b)

    return tot <= x
        
    

inp = map(int, sys.stdin.read().split())
n, a, b, *h = inp

l, r = 0, 10 ** 10
while l <= r:
    m = l + r >> 1
    if (check(h, a, b, m)):
        r, ans = m - 1, m
    else:
        l = m + 1

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
hs = [int(input()) for _ in range(N)]
def f(k):
    r = 0
    for h in hs:
        r += -(-max(0, (h-B*k)) // (A-B))
    return k>=r

mx,mn=10**18,0
idx=mx//2
while mx-mn>1:
    if f(idx):
        mx,idx=idx,(idx+mn)//2
        continue
    idx,mn=(idx+mx)//2,idx
print(idx+1)

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

def f(k):
    n = 0
    for h in H:
        if h <= B * k:
          break
        h -= B * k
        n += (h - 1) // (A - B) + 1
        if n > k:
            return False
    return True

hi = max(H)
lo = 0
while hi - lo > 1:
    m = (hi + lo) // 2
    if f(m):
        hi = m
    else:
        lo = m
print(hi)

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

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

l = 0
r = 10**9+1
while r-l > 1:
    m = (l+r)//2
    k = 0
    for h in H:
        c = max(0, h-m*B)
        k += c // (A-B)
        if c%(A-B) != 0: k += 1
    if k <= m:
        r = m
    else:
        l = m
print(r)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import copy
from collections import deque

class SegTree():
    def __init__(self, n):
        self.value = [0 for i in range(n*2)]

MOD = 10 ** 9 + 7

def getinvmod(n):
    return [pow(i, MOD-2, MOD) for i in range(n+1)]

def judge(monsters, n_attack, a, b):
    attack = 0
    for monster in monsters:
        
        if monster > 0:
            attack += math.ceil(max(0, (monster - b*n_attack)/(a-b)))

    return attack <= n_attack


def main():
    n, a, b = getList()
    monsters = []
    for i in range(n):
        monsters.append(getN())

    mn = 0
    mx = 10 ** 15
    while(mx - mn > 1):
        mid = (mn + mx) // 2
        if judge(monsters, mid, a, b):
            mx = mid
        else:
            mn = mid
        

    if judge(monsters, mn, a, b):
        print(mn)
    else:
        print(mx)



if __name__ == "__main__":
    main()

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

ng = 0
ok = sum([-(-h // A) for h in H])

while (ok - ng) > 1:
    mid = (ok + ng) // 2
    cnt = 0
    for h in H:
        if h <= B * mid:
            continue
        cnt += -(-(h - B * mid) // (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 _ in range(N)]


def func(x):
    attack = 0
    for h in H:
        hp = h - B * x
        if hp <= 0:
            continue
        attack += -(-hp // (A - B))
        
        
        
    if attack > x:
        return 0
    else:
        return 1


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


print(r)

Solution (Python):

import sys
input = sys.stdin.buffer.readline

INF = float("inf")

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

def Binary_Search(H, N, A, B):
	
	left = 0
	right = 2 * (10 ** 9)
	ans = INF
	ex = A - B
	
	
	while left <= right:
		mid = (left + right) // 2
		cnt = 0
		for i in range(N):
			if H[i] - mid * B > 0:
				if (H[i] - mid * B) % ex == 0:
					cnt += int((H[i] - mid * B) // ex)
				else:
					cnt += int((H[i] - mid * B) // ex) + 1
		
		if mid >= cnt:
			ans = min(ans, mid)
			right = mid - 1
		else:
			left = mid + 1

	return ans


def main():
	N, A, B = getlist()
	H = []
	for i in range(N):
		H.append(int(input()))
	
	ans = Binary_Search(H, N, A, B)
	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    H = [0] * N
    for i in range(N):
        H[i] = int(input())
    
    def isOK(x):
        cnt = 0
        for i in range(N):
            now = H[i] - B * x
            if now > 0:
                cnt += now // (A - B) if now % (A - B) == 0 else (now // (A - B)) + 1
            if cnt > x:
                return False
        return True
        

    def binary_search():
        ng = -1
        ok = 1010101010

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

            if (isOK(mid)):
                ok = mid
            else:
                ng = mid
        return ok

    ans = binary_search()
    print(ans)

    

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    
    import sys
    input = sys.stdin.readline
    
    N,A,B = map(int,input().split())
    H = []
    for i in range(N):
        h = int(input())
        H.append(h)
    H = sorted(H)[::-1]
    L = 0
    R = 10**9
    while 1:
        C = (L+R)//2
        tmp = 0
        for i in range(N):
            h = H[i]
            if h <= C*B:
                break
            else:
                tmp += int(-(-(h-C*B)//(A-B)))
        if tmp <= C:
            if C-1==L:
                ans = C
                break
            else:
                R = C
        else:
            if C+1==R:
                ans = R
                break
            else:
                L = C
    print(ans)
            
        
        
    
    
main()

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

def main():
    N,A,B = map(int,input().split())
    h = [int(input()) for _ in range(N)]
    left = 0
    right = math.ceil(max(h)/B)
    while right-left > 1:
        do = math.ceil((left+right)/2)
        count = 0
        for i in h:
            if i > do*B:
                count += math.ceil((i-do*B)/(A-B))
        if count > do:
            left = do
        else:
            right = do

    print(right)

if __name__ == "__main__":
    main()

Solution (Python):
import math

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

l = 0
r = 10**14

while True:
    e = (l+r)//2
    f = e
    for i in range(n):
        f -= math.ceil(max((h[i]-b*e),0)/(a-b))
        if f<0:
            break
    if f < 0:
        if l==e:
            print(e+1)
            exit()
        else:
            l = e
    else:
        r = e

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

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

l = 0
r = max(H)
T = 1
while r > l+1:
    T = (l+r)//2
    c = 0
    for h in H:
        if h > B*T:
            c += (h-B*T)//(A-B)
            if (h-B*T)%(A-B) != 0:
                c += 1
    if c <= T:
        r = T
    else:
        l = T

if l == T:
    print(T+1)
else:
    print(T)

Solution (Python):

import sys


def is_enough(n: int, d: int, B: int, h: "List[int]"):
    count = 0
    for hi in h:
        rest = hi - B * n
        if rest <= 0:
            break
        count += (rest + d - 1) // d
        if count > n:
            return False
    return n >= count


def solve(N: int, A: int, B: int, h: "List[int]"):
    h.sort(reverse=True)
    d = A - B

    right = (h[0] + B - 1) // B
    left = (h[0] - 1) // A
    
    while right - left > 1:
        mid = left + (right - left) // 2
        if is_enough(mid, d, B, h):
            right = mid
        else:
            left = mid
    
    print(right)
    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):
N,A,B=map(int,input().split())
H=[int(input()) for i in range(N)]
l,r=1,10**9
v={}
import math
def f(n):
    s=0
    for h in H:
        s+=max(0,math.ceil((h-B*n)/(A-B)))
    return s
a=10**9
while 1:
    n=(r-l)//2+l
    if n in v:
        n+=1
    if n in v:
        break
    v[n]=1
    s=f(n)
    if s<n:
        a=min(a,n)
        r=n
    elif s>n:
        a=min(a,s)
        l=n
    else:
        a=s
        break
print(a)

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

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

left, right = 0, (max(H) + B - 1)// B
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid): right = mid
    else: left = mid
print(right)

Solution (Python):
import math

def isOK(lis,attack):
    count = 0
    for i in lis:
        hp = i - B * attack
        if hp > 0:
            count += math.ceil(hp/(A - B))
    return count <= attack

def binary_search(lis):
    ng = -1
    ok = 10**10

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

N,A,B = [int(s) for s in input().split()]
lis = []

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

ans = binary_search(lis)
print(ans)

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

sys.setrecursionlimit(10 ** 7)

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


def judge(k: int, h: list, a:int, b:int):
    h = [max(0, hi - k*b) for hi in h]
    cnt = 0
    for hi in h:
        cnt += -(-hi//(a-b))

    return True if cnt <= k else False

def binary_search(h, a, b):
    low = 0
    high = 10**18

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

    return high

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

print(binary_search(h, a, b))

Solution (Python):
import math
n,a,b=map(int,input().split())
H=[]
for i in range(n):
  H.append(int(input()))
def f(k):
  count=0
  for i in range(n):
    count+=math.ceil(max(0,H[i]-k*b)/(a-b))
  if count<=k:
    return True
  else:
    return False
left,right=1,10**9
while left<right:
  k=(left+right)//2
  if f(k):
    right=k
  else:
    left=k+1
print(left)

Solution (Python):
import bisect
N,A,B=map(int,input().split())
C=A-B
H=[int(input()) for i in range(N)]
H.sort()
BIG=(H[-1]+B-1)//B
MAX=BIG
MIN=0
idx=(1,2)
def check(i):
    start=bisect.bisect_right(H,B*i)
    if start>=N:
        return True
    cnt=0
    for j in range(start,N):
        cnt+=(H[j]+C-1-B*i)//C
        if cnt>i:
            return False
    if cnt<=i:
        return True
    return False
while True:
    if MIN+1==MAX:
        break
    i=BIG*idx[0]//idx[1]
    if check(i):
        MAX=i
        idx=(idx[0]*2-1,idx[1]*2)
    else:
        MIN=i
        idx=(idx[0]*2+1,idx[1]*2)
print(MAX)

Solution (Python):

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

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

def jugde(n):
    count = 0
    for i in range(N):
        if (h[i]-B*n)%(A-B)==0:
            count+=max((h[i]-B*n)//(A-B),0)
        else:
            count+=max((h[i]-B*n)//(A-B)+1,0)
    if count<=n:
        return True
    else:
        return False

def bisect(i,j):
    if j-i==1:
        return j
    else:
        if jugde((i+j)//2):
            return bisect(i,(i+j)//2)
        else:
            return bisect((i+j)//2,j)

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

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

def check(k):
    cnt = 0
    for i in h:
        hp = i - k*b
        if hp > 0:
            cnt += -(-hp//(a-b))
    return cnt <= k

left = 0
right = 10**10
while right - left>1:
    mid = (right + left)//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)]

left = 1
right = max(h)
import math
def judge(x):
    cnt = 0
    tmp = 0
    for i in range(N):
        tmp = h[i] - B * x
        if tmp > 0:
            cnt += math.ceil(tmp/(A-B))
    if cnt <= x:
        return True
    else:
        return False
    
def binary(left,right):
    c = (left + right)//2
    if left >= right:
        for i in range(3):
            idx = left -1 + i
            if judge(idx):
                return (idx)
    if judge(c):
        right = c -1
        return binary(left,right)
    else:
        left = c + 1
        return binary(left,right)
    
    
ans = binary(left,right)
print(ans)

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

M.sort()


MAX=10**9
MIN=0
MID=-(-(MAX+MIN)//2)

for i in range(100):
    if (MAX-MIN)<=1:
        break
    else:
        cnt=0
        for j in range(len(M)):
            if (M[j]-MID*B)<=0:
                pass
            else:
                if (M[j]-MID*B)%(A-B)==0:
                    cnt+=(M[j]-MID*B)//(A-B)
                else:
                    cnt+=((M[j]-MID*B)//(A-B)+1)
        if cnt<=MID:
            MAX=MID
            MID=(MAX+MIN)//2
        else:
            MIN=MID
            MID=(MAX+MIN)//2

print(int(MAX))

Solution (Python):
def enough(t):
    cnt = 0
    for h in h_list:
        if h > b*t:
            cnt += -(-(h-b*t)//c)
    if cnt <= t:
        return True
    else:
        return False

n, a, b = map(int,input().split())
c = a - b
h_list = [int(input()) for _ in range(n)]
h_list.sort()
left = 0
right = -(-h_list[-1]//b)
while right - left > 1:
    mid = -(-(left + right)//2)
    if enough(mid):
        right = mid
    else:
        left = mid

print(right)

Solution (Python):
a,b,c = map(int, input().split())
l = [int(input()) for _ in range(a)]
flag = True
l = sorted(l)
max_T = 10**18
def ok(k):
    s = k
    for i in l:
        hp = i - c * k
        if hp > 0:
            s -= -(-hp // (b - c))
        if s < 0:
            return False
    return True
def binary_search(l,r):
    mid = (l + r) // 2
    if l == r:
        return l
    elif ok(mid):
        return binary_search(l,mid)
    else:
        if mid == l:
            mid += 1
            
        return binary_search(mid,r)
ans = binary_search(0,max_T)
print(ans)

Solution (Python):
def solve():
    N, A, B = map(int, input().split())
    h = []
    for _ in range(N):
        h.append(int(input()))
    ans_min = 0
    ans_max = 10 ** 9
    while ans_min + 1 < ans_max:
        ans = (ans_min + ans_max) // 2
        count = 0
        for i in h:
            count += (max(0, i - B * ans) + A - B - 1) // (A - B)
        if count > ans:
            ans_min = ans
        else:
            ans_max = ans
    print(ans_max)
    return
solve()

Solution (Python):
def solve():
    N, A, B = map(int, input().split())
    h = []
    for _ in range(N):
        h.append(int(input()))
    ans_min = 0
    ans_max = 10 ** 9
    while ans_min + 1 < ans_max:
        ans = (ans_min + ans_max) // 2
        count = 0
        for i in h:
            count += (max(0, i - B * ans) + A - B - 1) // (A - B)
        if count > ans:
            ans_min = ans
        else:
            ans_max = ans
    print(ans_max)
    return
solve()

Solution (Python):
N,A,B = map(int,input().split())
h = []
for _ in range(N):
    h.append(int(input()))
h.sort(reverse=True)
def judge(M):
    i = 0
    j = M
    while True:
        if i >= N:
            return(True)
        if h[i] <= M*B:
            return(True)
        diff = h[i] - M*B
        needs = diff//(A-B)
        if diff%(A-B) != 0:
            needs += 1
        
        j -= needs
        if j < 0:
            return(False)
        i += 1

ok = N*10**9
ng = 0
while ok > ng + 1:
    mid = (ok+ng)//2
    if judge(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)]
def judige(n):
    global h,a,b
    check = 0
    for i in range(len(h)):
        num = h[i]
        num -= b*n
        if num > 0:
            check += num//(abs(b-a)) if num % abs(b-a) == 0 else num//abs(b-a) + 1
    if check <= n:return True
    return False
inf = max(h)//b + 1
zero = 0
while True:
    num = (inf+zero)//2
    if inf-zero==1 or inf-zero==0:break
    if judige(num):inf = num
    else:zero = num
if judige(zero-2) and zero > 2:print(zero-2)
elif judige(zero-1) and zero > 1:print(zero-1)
elif judige(zero):print(zero)
else:print(inf)

Solution (Python):
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
def judige(n):
    global h,a,b
    check = 0
    for i in range(len(h)):
        num = h[i]
        num -= b*n
        if num > 0:
            check += num//(abs(b-a)) if num % abs(b-a) == 0 else num//abs(b-a) + 1
    if check <= n:return True
    return False
inf = max(h)//b + 1
zero = 0
while True:
    num = (inf+zero)//2
    if inf-zero==1 or inf-zero==0:break
    if judige(num):inf = num
    else:zero = num
if judige(zero-2) and zero > 2:print(zero-2)
elif judige(zero-1) and zero > 1:print(zero-1)
elif judige(zero):print(zero)
else:print(inf)

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

ok=max(H)//B+1
ng=0
mid=(ok+ng)//2
while ok-ng>1:
  cntlive=0
  for h in H:
    h-=B*mid
    if h>0:
      cntlive+=(h+A-B-1)//(A-B)
  if cntlive<=mid:
    ok=mid
  else:
    ng=mid
  mid=(ok+ng)//2
print(ok)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def ceil(x):
    return int((-x)//1*(-1))


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


def check(x, HP):
    cnt = 0
    for i in range(N):
        if HP[i]-B*x <= 0:
            break
        else:
            cnt += ceil((HP[i]-B*x)/diff)
    return cnt <= x


def solve2():
    HP = sorted(hp, reverse=True)
    mi = HP[0]//A
    ma = ceil(HP[0]/B)
    while mi <= ma:
        mid = (mi+ma)//2
        if check(mid, HP):
            ma = mid-1
        else:
            mi = mid+1
    print(mi)


def check2(x, hp):
    l = [a-B*x for a in hp]
    ret = 0
    for a in l:
        if a <= 0:
            continue
        else:
            ret += ceil(a/diff)
    return ret <= x


def solve3():
    mi = max(hp)//A
    ma = ceil(max(hp)/B)
    while mi <= ma:
        mid = (mi+ma)//2
        if check2(mid, hp):
            ma = mid-1
        else:
            mi = mid+1
    print(mi)


solve3()

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def ceil(x):
    return int((-x)//1*(-1))


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


def check(x, HP):
    cnt = 0
    for i in range(N):
        if HP[i]-B*x <= 0:
            break
        else:
            cnt += ceil((HP[i]-B*x)/diff)
    return cnt <= x


def solve2():
    HP = sorted(hp, reverse=True)
    mi = HP[0]//A
    ma = ceil(HP[0]/B)
    while mi <= ma:
        mid = (mi+ma)//2
        if check(mid, HP):
            ma = mid-1
        else:
            mi = mid+1
    print(mi)


def check2(x, hp):
    l = [a-B*x for a in hp]
    ret = 0
    for a in l:
        if a <= 0:
            continue
        else:
            ret += ceil(a/diff)
    return ret <= x


def solve3():
    mi = max(hp)//A
    ma = ceil(max(hp)/B)
    while mi <= ma:
        mid = (mi+ma)//2
        if check2(mid, hp):
            ma = mid-1
        else:
            mi = mid+1
    print(mi)


solve3()

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def ceil(x):
    return int((-x)//1*(-1))


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


def check(x, HP):
    cnt = 0
    for i in range(N):
        if HP[i]-B*x <= 0:
            break
        else:
            cnt += ceil((HP[i]-B*x)/diff)
    return cnt <= x


def solve2():
    HP = sorted(hp, reverse=True)
    mi = HP[0]//A
    ma = ceil(HP[0]/B)
    while mi <= ma:
        mid = (mi+ma)//2
        if check(mid, HP):
            ma = mid-1
        else:
            mi = mid+1
    print(mi)


solve2()

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

def func(k):
    hn = [a - k*B for a in h]
    res = 0
    for i in range(N):
        if hn[i] > 0:
            res += (hn[i]-1+A)//A
    return res <= k

left = 0
right = hmax//B + 1
while True:
    if left == right:
        break
    half = (left + right)//2
    if func(half):
        right = half
    else:
        left = half + 1
print(left)

Solution (Python):
from math import ceil
def solve(val):
	z = 0
	for i in range(n):
		if h[i] <= val*b:
			pass
		else:
			z += ((h[i]-val*b-1)/(a-b))+1
	if z <= val:
		return True
	else:
		return False
n,a,b = map(int,raw_input().split())
h = [input() for i in range(n)]
lo,hi = 1,10**9
while lo < hi:
	mid = lo+(hi-lo)//2
	if solve(mid):
		hi = mid
	else:
		lo = mid+1
print lo

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

def check(k):
    top = 0
    tmp = h[::]
    for i in range(n):
        amari = tmp[i] - b*k
        if amari > 0:
            top += -(-amari//(a-b))
    return top <= k


left = 0
right = -(-1*sum(h)//b)
while(right-left>1):
    next_ind = (left + right)//2
    if check(next_ind):
        right = next_ind
    else:
        left = next_ind
print(right)