Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
sys.setrecursionlimit(10 ** 6)
def main():
    import sys
    input = sys.stdin.readline
    
    n,a,b = map(int,input().split())
    H = []
    for _ in range(n):
        h = int(input())
        H.append(-h)
    heapq.heapify(H)
    ans = 0
    dm = 0
    d = a-b
    while True:
        mx = heapq.heappop(H)
        if mx+dm <0:
            mx += d
            dm += b
            ans += 1
            heapq.heappush(H, mx)
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import math
n,a,b = map(int,input().split())
H = list(int(input()) for _ in range(n))
l,r = 0, 10**9
d = a-b
while r-l>1:
    mid = (r+l)//2
    tmp = 0
    for h in H:
        if h <= mid*b:
            continue
        tmp += math.ceil((h-mid*b)/d)
    if tmp <= mid:
        r = mid
    else:
        l = mid
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n,a,b = map(int,input().split())
H = []
for _ in range(n):
    h = int(input())
    H.append(-h)
heapq.heapify(H)
ans = 0
dm = 0
d = a-b
while True:
    mx = heapq.heappop(H)
    if mx+dm <0:
        mx += d
        dm += b
        ans += 1
        heapq.heappush(H, mx)
    else:
        break
print(ans)


Fixed submission:
import math
n,a,b = map(int,input().split())
H = list(int(input()) for _ in range(n))
l,r = 0, 10**9
d = a-b
while r-l>1:
    mid = (r+l)//2
    tmp = 0
    for h in H:
        if h <= mid*b:
            continue
        tmp += math.ceil((h-mid*b)/d)
    if tmp <= mid:
        r = mid
    else:
        l = mid
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n,a,b = map(int,input().split())
H = []
for _ in range(n):
    h = int(input())
    H.append(-h)
heapq.heapify(H)
ans = 0
dm = 0
d = a-b
while True:
    mx = heapq.heappop(H)
    if mx+dm <0:
        mx += d
        dm += b
        ans += 1
        heapq.heappush(H, mx)
    else:
        break
print(ans)

Fixed submission:
import math
n,a,b = map(int,input().split())
H = list(int(input()) for _ in range(n))
l,r = 0, 10**9
d = a-b
while r-l>1:
    mid = (r+l)//2
    tmp = 0
    for h in H:
        if h <= mid*b:
            continue
        tmp += math.ceil((h-mid*b)/d)
    if tmp <= mid:
        r = mid
    else:
        l = mid
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
class Range_BIT:
    def __init__(self, n):
        self.n = n
        self.bit0 = [0]*(n+1)
        self.bit1 = [0]*(n+1)
    
    def _Add(self, k, x, is_bit0=True):
        if is_bit0 == True:
            data = self.bit0
        else:
            data = self.bit1
        while k <= self.n:
            data[k] += x
            k += k & -k
    
    def _Get(self, data, k):
        s = 0
        while k:
            s += data[k]
            k -= k&-k
        return s
    
    """ 配列の獲得 """
    def Array(self):
        array = [0]*(n+1)
        for i in range(self.n):
            array[i] = self.Get(i+1,i+2)
        return array[:-1]
    
    """ 区間[l:r)に対してxを加算 """
    def Add(self, l, r, x):
        self._Add(l, -x*(l-1), is_bit0=True)
        self._Add(r, x*(r-1), is_bit0=True)
        self._Add(l, x, is_bit0=False)
        self._Add(r, -x, is_bit0=False)
    
    """ 区間[l:r)の総和 """
    def Get(self, l, r):
        Pi = self._Get(self.bit1, r-1)*(r-1) - self._Get(self.bit1, l-1)*(l-1)
        Qi = self._Get(self.bit0, r-1) - self._Get(self.bit0, l-1)
        return Pi+Qi

n,a,b = map(int,input().split())
d = a-b
rbit = Range_BIT(n)
for i in range(n):
    h = int(input())
    rbit.Add(i+1, i+2, h)
ans = 0
while True:
  arr = rbit.Array()
  mx = max(arr)
  idx = arr.index(mx)
  if mx <= 0:
    break
  rbit.Add(1,n+1,-b)
  rbit.Add(idx+1, idx+2, -d)
  ans += 1
print(ans)

Fixed submission:
import math
n,a,b = map(int,input().split())
H = list(int(input()) for _ in range(n))
l,r = 0, 10**9
d = a-b
while r-l>1:
    mid = (r+l)//2
    tmp = 0
    for h in H:
        if h <= mid*b:
            continue
        tmp += math.ceil((h-mid*b)/d)
    if tmp <= mid:
        r = mid
    else:
        l = mid
print(r)