Buggy python submission (verdict: Time Limit Exceeded):
import math
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    count+=max(0,math.ceil((S[i]-B*T)/(A-B)))
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)

Fixed submission:
import math
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    a=math.ceil((S[i]-B*T)/(A-B))
    if a>0:
      count+=a
    else:
      break
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    if (S[i]-B*T)/(A-B)%1==0:
      count+=max(0,int((S[i]-B*T)/(A-B)))
    else:
      count+=max(0,int((S[i]-B*T)/(A-B))+1)
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)

Fixed submission:
import math
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    a=math.ceil((S[i]-B*T)/(A-B))
    if a>0:
      count+=a
    else:
      break
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
count=0

def Check(T):
  count=0
  for i in range(N):
    count+=int((S[i]-B*T)/(A-B))
  if count<=T:
    return 1
  else:
    return 0

L=-1#二分探索の指数
T=1#checkしたいナンバー。
while True:
  if Check(T)==0:
    L+=1
    T+=2**L
  if Check(T)==1:
    L-=1
    if L==0:
      print(T)
      sys.exit() 
    T-=2**L

Fixed submission:
import math
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    a=math.ceil((S[i]-B*T)/(A-B))
    if a>0:
      count+=a
    else:
      break
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
count=0
S.sort()
C=A-B
h=[S[0]]
for i in range(N-1):
  if S[i+1]>=S[0]*(B/A):
    h+=[S[i+1]]
  else:
    break

N=len(h)

while True:
  h.sort(reverse=1)
  if h[0]<=0:
    print(count)
    sys.exit()
  if (h[0]/A)%1==0:
    t=int(h[0]/A)
  else:
    t=int(h[0]/A)+1
  for i in range(N):
    h[i]-=B*t
  for j in range(t):
    h.sort(reverse=1)
    h[0]-=C
  count+=t

Fixed submission:
import math
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    a=math.ceil((S[i]-B*T)/(A-B))
    if a>0:
      count+=a
    else:
      break
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
count=0
S.sort()
h=[S[0]]
for i in range(N-1):
  if S[i+1]>=S[0]*(B/A):
    h+=[S[i+1]]
  else:
    break

N=len(h)

while True:
  h.sort(reverse=1)
  if h[0]<=0:
    print(count)
    sys.exit()
  if (h[0]/A)%1==0:
    t=int(h[0]/A)
  else:
    t=int(h[0]/A)+1
  h[0]-=A*t
  for i in range(N-1):
    h[i+1]-=B*t
  count+=t
  if h[N-1]<=-A:
    if (h[N-1]/A)%1==0:
      t=-int(h[N-1]/A)
    else:
      t=-int(h[N-1]/A)
    h[N-1]+=t*(A-B)
    for i in range(N):
      h[i]+=t*B
    count-=t

Fixed submission:
import math
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    a=math.ceil((S[i]-B*T)/(A-B))
    if a>0:
      count+=a
    else:
      break
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,A,B=map(int,input().split())
h=[]
for i in range(N):
  h+=[int(input())] 
count=0

while True:
  h.sort(reverse=1)
  if h[0]<=0:
    print(count)
    sys.exit()
  if (h[0]/A)%1==0:
    t=int(h[0]/A)
  else:
    t=int(h[0]/A)+1
  h[0]-=A*t
  for i in range(N-1):
    h[i+1]-=B*t
  count+=t
  if h[N-1]<=-A:
    if (h[N-1]/A)%1==0:
      t=-int(h[N-1]/A)
    else:
      t=-int(h[N-1]/A)
    h[N-1]+=t*(A-B)
    for i in range(N):
      h[i]+=t*B
    count-=t

Fixed submission:
import math
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    a=math.ceil((S[i]-B*T)/(A-B))
    if a>0:
      count+=a
    else:
      break
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,A,B=map(int,input().split())
h=[]
for i in range(N):
  h+=[int(input())] 
count=0
C=A-B

while True:
  h.sort(reverse=1)
  if h[0]<=0:
    print(count)
    sys.exit()
  else:
    h[0]-=A
    for i in range(N-1):
      h[i+1]-=B
    count+=1

Fixed submission:
import math
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    a=math.ceil((S[i]-B*T)/(A-B))
    if a>0:
      count+=a
    else:
      break
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)