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



Sample input:
4 5 3
8
7
4
2


Sample output:
2

Submission status: Wrong Answer

Solution code:
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 l < r:
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m + 1
    # print(r, l, m)
        
print(m)

Submission status: Wrong Answer

Solution code:
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 l < r:
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m + 1
    print(r, l, m)
        
print(m)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
    
l = 0
r = 10 ** 9 + 7
while l < r:
    m = (l + r) // 2
    ans = 0
    for i in range(N):
        ans += - (- (H[i] - (B * m)) // (A - B))
    if ans < m:
        r = m
    else:
        l = m + 1
        
print(m)

Submission status: Wrong Answer

Solution code:
def roof(x):
    if x == int(x):
        return x
    else:
        return int(x)+1

def ans(n,a,b,h):
    s = sum(h)
    
    m = max(h)

    M = int(m / b)
    
    x = M
    y = 0
    
    if x ==1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            x = half
        else:
            y = half
        #print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

for i in range(0,n):
    h[i] = int(input())

print(ans(n,a,b,h))

Submission status: Wrong Answer

Solution code:
def roof(x):
    if x == int(x):
        return x
    else:
        return int(x)+1

def ans(n,a,b,h):
    s = sum(h)
    
    m = max(h)

    M = int(m / b)
    
    x = M
    y = 0
    
    if x ==1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            x = half
        else:
            y = half
        print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

for i in range(0,n):
    h[i] = int(input())

print(ans(n,a,b,h))

Submission status: Wrong Answer

Solution code:
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 + 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())

Submission status: Wrong Answer

Solution code:
import bisect
N,A,B=map(int,input().split())

M=[]
for i in range(N):
    m=int(input())
    M.append(m)
    
M.sort()
M.append(10**10)

#L=[M[0]]
#for i in range(N):
#    L.append(L[i]+M[i+1])
    
HIG=10**9
MID=5*(10**8)
LOW=0
#print(M)
for i in range(100):
    P=bisect.bisect_left(M,MID)
    cnt=0
    for j in range(P,N):
        if (M[j]-(B*MID))%(A-B)==0:
            cnt+=int((M[j]-(B*MID))//(A-B))
        else:
            cnt+=int((M[j]-(B*MID))//(A-B))+1
    if cnt>=MID:
        MID,LOW=(HIG+MID)/2,MID
    else:
        MID,HIG=(LOW+MID)/2,MID

        
#print(HIG)
print(int(HIG+0.99))

Submission status: Wrong Answer

Solution code:
import bisect
N,A,B=map(int,input().split())

M=[]
for i in range(N):
    m=int(input())
    M.append(m)
    
M.sort()
M.append(10**10)

#L=[M[0]]
#for i in range(N):
#    L.append(L[i]+M[i+1])
    
HIG=10**9
MID=5*(10**8)
LOW=0
#print(M)
for i in range(50):
    P=bisect.bisect_left(M,MID)
    cnt=0
    for j in range(P,N):
        if (M[j]-(B*MID))%(A-B)==0:
            cnt+=int((M[j]-(B*MID))/(A-B))
        else:
            cnt+=int((M[j]-(B*MID))/(A-B))
    if cnt>=MID:
        MID,LOW=(HIG+MID)/2,MID
    else:
        MID,HIG=(LOW+MID)/2,MID
    
print(int(MID+0.01))

Submission status: Wrong Answer

Solution code:
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  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 isDel(t):
  x=0
  for h in H:
    x+=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 isDel(t):
    ans=t
    TMax=t
  else:
    TMin=t+1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  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 isDel(t):
  x=0
  for h in H:
    x+=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 isDel(t):
    ans=t
    TMax=t
  else:
    TMin=t+1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  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 isDel(t):
  x=0
  for h in H:
    x+=math.ceil((h-B*t)/C)
    if x>t: break
  return (t>=x)

t=TMax
while TMax>TMin:
  t=math.ceil((TMax+TMin)/2)
  if isDel(t):
    TMax=t
  else:
    TMin=t+1
print(TMax)

Submission status: Wrong Answer

Solution code:
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  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 isDel(t):
  x=0
  for h in H:
    x+=math.ceil((h-B*t)/C)
    if x>t: break
  return (t>=x)

t=TMax
while TMax>TMin:
  t=(TMax+TMin)//2
  if isDel(t):
    TMax=t
  else:
    TMin=t+1
print(TMax)

Submission status: Wrong Answer

Solution code:
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):
    middle = (left+right) // 2
    while left < middle < right:
        if judge(middle) is True:
            right = middle
        else:
            left = middle+1
        middle = (left+right) // 2
    return middle
rec = biserch()
print(rec)

Submission status: Wrong Answer

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

from math import ceil

ng,ok = 0,10**9+1
while ok!=ng>1:
    mid = (ng+ok)//2
    cnt = 0
    for i in range(N):
        cnt += max(ceil((H[i] - B*mid)/(A-B)) ,0)
    if cnt <= mid:
        ok = mid
    else:
        ng = mid

print(ok)

Submission status: Wrong Answer

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

from math import ceil

ng,ok = 0,10**9+1
while abs(ok-ng)>1:
    mid = (ng+ok)//2
    cnt = 0
    for i in range(N):
        cnt += max(ceil((H[i] - B*mid)/(A-B)) ,0)
    if cnt == mid:
        break
    if cnt <= mid:
        ok = mid
    else:
        ng = mid

print(ok)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
s = IR(n)
su = sum(s)
dp = [[0 for i in range(su+1)] for j in range(n)]
dp[0][s[0]] = 1
for i in range(n):
    dp[i][0] = 1
for i in range(1,n):
    for j in range(su+1)[::-1]:
        if s[i]+j <= su:
            dp[i][s[i]+j] = max(dp[i][s[i]+j],dp[i-1][j])
        dp[i][j] = max(dp[i][j],dp[i-1][j])
for i in range(su+1)[::-1]:
    if dp[n-1][i] == 1 and i%10 != 0:
        break
print(i)
"""

#D
n,a,b = LI()
h = IR(n)
l = 0
r = math.ceil(max(h)/b)+10
while r-l > 1:
    m = (l+r)//2
    k = 0
    for i in range(n):
        k += math.ceil((h[i]-b*m)/(a-b))
        if k > m:break
    if k > m:
        l = m
    else:
        r = m
print(r)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
s = IR(n)
su = sum(s)
dp = [[0 for i in range(su+1)] for j in range(n)]
dp[0][s[0]] = 1
for i in range(n):
    dp[i][0] = 1
for i in range(1,n):
    for j in range(su+1)[::-1]:
        if s[i]+j <= su:
            dp[i][s[i]+j] = max(dp[i][s[i]+j],dp[i-1][j])
        dp[i][j] = max(dp[i][j],dp[i-1][j])
for i in range(su+1)[::-1]:
    if dp[n-1][i] == 1 and i%10 != 0:
        break
print(i)
"""

#D
n,a,b = LI()
h = IR(n)
l = 1
r = math.ceil(max(h)/b)+10
while r-l > 1:
    m = (l+r)//2
    k = 0
    for i in range(n):
        k += math.ceil((h[i]-b*m)/(a-b))
        if k > m:break
    if k > m:
        l = m
    else:
        r = m
print(r)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
s = IR(n)
su = sum(s)
dp = [[0 for i in range(su+1)] for j in range(n)]
dp[0][s[0]] = 1
for i in range(n):
    dp[i][0] = 1
for i in range(1,n):
    for j in range(su+1)[::-1]:
        if s[i]+j <= su:
            dp[i][s[i]+j] = max(dp[i][s[i]+j],dp[i-1][j])
        dp[i][j] = max(dp[i][j],dp[i-1][j])
for i in range(su+1)[::-1]:
    if dp[n-1][i] == 1 and i%10 != 0:
        break
print(i)
"""

#D
n,a,b = LI()
h = IR(n)
l = 1
r = math.ceil(max(h)/b)
while r-l > 1:
    m = (l+r)//2
    k = 0
    for i in range(n):
        k += math.ceil((h[i]-b*m)/(a-b))
        if k > m:break
    if k > m:
        l = m
    else:
        r = m
print(r)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
s = IR(n)
su = sum(s)
dp = [[0 for i in range(su+1)] for j in range(n)]
dp[0][s[0]] = 1
for i in range(n):
    dp[i][0] = 1
for i in range(1,n):
    for j in range(su+1)[::-1]:
        if s[i]+j <= su:
            dp[i][s[i]+j] = max(dp[i][s[i]+j],dp[i-1][j])
        dp[i][j] = max(dp[i][j],dp[i-1][j])
for i in range(su+1)[::-1]:
    if dp[n-1][i] == 1 and i%10 != 0:
        break
print(i)
"""

#D
n,a,b = LI()
h = IR(n)
l = 0
r = math.ceil(max(h)/b)
while r-l > 1:
    m = (l+r)//2
    k = 0
    for i in range(n):
        k += math.ceil((h[i]-b*m)/(a-b))
        if k > m:break
    if k > m:
        l = m
    else:
        r = m
print(r)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
s = IR(n)
su = sum(s)
dp = [[0 for i in range(su+1)] for j in range(n)]
dp[0][s[0]] = 1
for i in range(n):
    dp[i][0] = 1
for i in range(1,n):
    for j in range(su+1)[::-1]:
        if s[i]+j <= su:
            dp[i][s[i]+j] = max(dp[i][s[i]+j],dp[i-1][j])
        dp[i][j] = max(dp[i][j],dp[i-1][j])
for i in range(su+1)[::-1]:
    if dp[n-1][i] == 1 and i%10 != 0:
        break
print(i)
"""

#D
n,a,b = LI()
h = IR(n)
l = 0
r = math.ceil(max(h)/b)
while r-l > 1:
    m = (l+r)//2
    k = 0
    for i in range(n):
        k += math.ceil((h[i]-b*m)/(a-b))
        if k > m:break
    if k <= m:
        r = m
    else:
        l = m
print(r)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
from math import ceil
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
A -= B  # Aを追加ダメージ扱いにする


ok, ng = 10 ** 9, 0
while abs(ok - ng) > 1:
    X = (ok + ng) // 2
    H_damaged = [h - (B * X) for h in H if h - B > 0]
    Need = sum([ceil(h / A) for h in H_damaged])

    if X >= Need:
        ok = X
    else:
        ng = X

print(ok)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,*h=map(int,open(0).read().split());i,j=0,2**30
while j-i>1:
 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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,*h=map(int,open(0).read().split())
i,j=0,max(h)*n//a
while True:
  if j-i<2:
    print(j)
    break
  k=c=(j+i+1)//2
  for t in h:
    t-=b*k
    if t>0:
      c+=-t//(a-b)
  if c>=0:
    j=k
  else:
    i=k

Submission status: Wrong Answer

Solution code:
from math import ceil

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

K=ceil(sum(h)/(A+(N-1)*B))
ans=0

for hi in h:
    if hi-B*K>0:
        ans+=ceil((hi-B*K)/(A-B))

print(ans)

Submission status: Wrong Answer

Solution code:
import math


def solve(N, A, B, Hs):
    k_min = 1
    k_max = 10 ** 9
    d = A - B
    # print(N, ",", A, ",", B, ",", Hs)

    def find(k):
        # print("find %d" % k)
        kc = sum([max(math.ceil((h - B * k) / d), 0) for h in Hs])
        return kc <= k

    def bin_search(k_min, k_max):
        if k_max - k_min <= 1:
            return k_max
        # print("find %d, %d" % (k_min, k_max))
        k_mid = (k_max + k_min) // 2
        m = find(k_mid)
        if m:
            return bin_search(k_min, k_mid)
        else:
            return bin_search(k_mid, k_max)

    return bin_search(k_min, k_max)

if __name__ == "__main__":
    N, A, B = tuple(map(int, input().split(" ")))
    Hs = []
    for _ in range(N):
        Hs.append(int(input()))
    print(solve(N, A, B, Hs))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))


def check(m):
    cnt = 0
    for i in range(N):
        cnt += -(-(h[i]-m*B)//(A-B))
    return cnt <= m


def binary_search(l, r):
    c = (l+r)//2
    if r-l == 1:
        return l if check(c) else r

    if check(c):
        return binary_search(l, c)
    else:
        return binary_search(c, r)

print(binary_search(0, 10**11))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))


def check(m):
    cnt = 0
    for i in range(N):
        cnt += -(-(h[i]-m*B)//(A-B))
    print(m, cnt)
    return cnt <= m


def binary_search(l, r):
    c = (l+r)//2
    if r-l == 1:
        return l if check(c) else r

    if check(c):
        return binary_search(l, c)
    else:
        return binary_search(c, r)

print(binary_search(0, 10**11))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))

M = -(-sum(h)//(A+(N-1)*B))


def check(m):
    cnt = 0
    for i in range(N):
        cnt += -(-(h[i]-m*B)//(A-B))
    return cnt <= m


def binary_search(l, r):
    c = (l+r)//2
    if r-l == 1:
        return l if check(c) else r

    if check(c):
        return binary_search(l, c)
    else:
        return binary_search(c, r)

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

Submission status: Wrong Answer

Solution code:
import math
import copy

def condition(t, h, a, b):
    _h = copy.deepcopy(h)
    count = 0
    for i in range(len(_h)):
        _h[i] -= b*t
        if _h[i] > 0:
            count += math.ceil(_h[i]/(a-b))
            _h[i] -= a*math.ceil(_h[i]/(a-b))
    # print("count:{} t:{} _h:{} a:{} b:{}".format(count, t, _h, a, b))
    if count > t:
        return False
    else:
        return True


class binarySearch:
    # 添え字による二分探索
    # 添え字「t」によってソート済みリストを二分探索
    def __init__(self, limit, target):
        self.limit = limit
        self.target = target

    # min(table) <= target <= max(table)が前提
    def search(self, h, a, b):
        low = 0
        high = self.limit
        # t は中央番目の数
        t = int((low + high) / 2)
        out = -1
        # 探索の下限のlowが上限のhighになるまで探索
        # lowがhighに達すると数は見つからなかったということ
        while high >= low:
            # ここで入力tに対する結果出力
            out = condition(t, h, a, b)
            # print("t:{} _out:{} limit:{}\n".format(t, out, self.limit))
            if out == self.target:
                break
            if not out:
                low = t + 1
            else:
                high = t - 1
            t = int((low + high) / 2)
        # 条件式「func(t) <= limit」
        # を満たす中で最大の「t」を返す
        return low

def func(a, b, _h):
    _h.sort()
    _h.reverse()
    _sum = 0  # 現在何回以上爆発させることが確定しているか
    aMargin = 0  # _sum回のうちあと何回aを使うことができるか
    for h in _h:
        print("prev cost upper:{}".format(a * aMargin + b * (_sum - aMargin)))
        # まず_sum回で抑える場合にaがいくつ必要か算出
        if h <= a * aMargin + b * (_sum - aMargin):
            # そのうちどれだけaを使わないでいられるか
            h -= b * _sum  # まず必ず減る部分を計算
            if h > 0:
                aMargin -= math.ceil(h / (a - b))  # a が何回必要か
        else:
            # hを0にするのに必要最低限の回数をを算出
            tmpH = h
            tmpH -= a * aMargin + b * (_sum - aMargin)
            extra = math.ceil(tmpH / a)
            _sum += extra
            aMargin += extra
            print("aMargin:{}".format(aMargin))
            # 合計して「_sum」回が最小回数
            # ここで使えるaは「aMargin」回
            # そのうちどれだけaを使わないでいられるか
            h -= b * _sum  # まず必ず減る部分を計算
            aMargin -= math.ceil(h / (a - b))  # a が何回必要か
        print("_sum:{} margin:{}".format(_sum, aMargin))
    return str(_sum)


n, a, b = [int(i) for i in input().split()]
h = [0 for _ in range(n)]
for i in range(n):
    h[i] = int(input())
# print(func(a, b, h))
binary = binarySearch(target=math.ceil(max(h)/a), limit=math.ceil(max(h)/1))
print(binary.search(h, a, b))
# print("print(func({}, {}, {}))".format(a, b, h))
"""
print("2 vs " + func(5, 3, [8, 7, 4, 2]))
print("4 vs " + func(10, 4, [20, 20]))
print("800000000 vs " + func(2, 1, [900000000, 900000000, 1000000000, 1000000000, 1000000000]))
"""

Submission status: Wrong Answer

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


def enough(x):
    return sum([1 + (max(h - B * x, 0) - 1) // (A - B) for h in H]) <= x


ng = 0
ok = max(H) - 1

while ok - ng > 1:
    half = (ok + ng) // 2
    if enough(half):
        ok = half
    else:
        ng = half
print(ok)

# https://img.atcoder.jp/arc075/editorial.pdf

Submission status: Wrong Answer

Solution code:
def judge(h,t,a,b,n):
    counter = 0
    for i in range(n):
        if h[i] > b*t:
            if ((h[i]-b*t)/(a-b))%1 == 0:
                counter += (h[i]-b*t)//(a-b)
            else:
                counter += (h[i]-b*t)//(a-b) + 1
    if counter <= t:
        return True
    else:
        return False

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

left = 1
right = max(h)//b + 1

while abs(right-left) > 1:
    check = judge(h,(left+right)//2,a,b,n)
    if check:
        right = (left+right)//2
    else:
        left = (left+right)//2

print(right)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,raw_input().split())
a = []
x = 0
C = A-B
for i in range(N):
	a.append(int(raw_input()))
a.sort()
n = 0
while max(a)>0:
	Y = a.index(max(a))
	a[Y]-=C
	map(lambda x: x-B,a)
	n += 1
print n

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
h = [int(m) for m in d]#int型に直す
#print(x)

low = 0
high = math.ceil(max(h)/b)
# t は中央番目の数
t = (low + high) // 2

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかっTrueたということ
X = 0
Y = 0
s = 0
while high - low >= 1:
    for j in range(n):
        X += max(0, math.ceil((h[j] - t * b) / (a - b)))
        #Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))
    if X == t:
        print(t)
        exit()
    elif X < t:
        high = t - 1
        """for j in range(n):
            Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))"""
    elif X > t:
        low = t + 1
    s = t
    t = (low + high) // 2
    X = 0
    Y = 0
print(s)

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
h = [int(m) for m in d]#int型に直す
#print(x)

low = 0
high = math.ceil(max(h)/b)
# t は中央番目の数
t = (low + high) // 2

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかっTrueたということ
X = 0
Y = 0
s = 0
while abs(low - high) >= 1:
    for j in range(n):
        X += max(0, math.ceil((h[j] - t * b) / (a - b)))
        #Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))
    if X == t:
        print(t)
        exit()
    elif X < t:
        high = t - 1
        """for j in range(n):
            Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))"""
    elif X > t:
        low = t + 1
    s = t
    t = (low + high) // 2
    X = 0
    Y = 0
print(s)

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
h = [int(m) for m in d]#int型に直す
#print(x)

low = 0
high = math.ceil(max(h)/b)
# t は中央番目の数
t = (low + high) // 2

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかっTrueたということ
X = 0
Y = 0
while True:
    for j in range(n):
        X += math.ceil((h[j] - t * b) / (a - b))
    if X <= t:
        for j in range(n):
            Y += math.ceil((h[j] - (t - 1) * b) / (a - b))
        if Y > t - 1:
            print(t)
            exit()
        else:
            high = t - 1
    elif X > t:
        low = t + 1
    t = (low + high) // 2
    X = 0
    Y = 0

Submission status: Wrong Answer

Solution code:
import math
n,a,b=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
def sten(t):
    dh=[]
    for i in range(n):
        if h[i]-t*b>0:
            dh.append(h[i]-t*b)
    aan=0
    for i in range(len(dh)):
        aan+=math.ceil(dh[i]/(a-b))
    if aan<=t:
        return True
    else:
        return False
an=[0 for i in range(max(h)//b+1)]
l,r=0,len(an)
while True:
    m=(l+r)//2
    if sten(m+1):
        an[m]=True
        if an[m-1]==False:
            print(m+1)
            break
        r=m-1
    else:
        an[m]=False
        if an[m+1]==True:
            print(m+2)
            break
        l=m+1

Submission status: Wrong Answer

Solution code:

import math
"""
def search(min_,max_,A,B,arr):
#    print(min_,max_)
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=arr-mid*B
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=map(lambda x:math.ceil(x/(A-B)),tmp)
    sum_=sum(list(tmp))
    if sum_<=mid:
        return search(min_,mid,A,B,arr)
    else:
        return search(mid+1,max_,A,B,arr)

    while True:
        if k<0:
            if mid==min_:
                return max_
            else:
                #failure
                return search(mid,max_,A,B,arr[:L])
        elif len(tmp)==0:
            #success
            return search(min_,mid,A,B,arr)
        x=-tmp[0]
        tmp=np.delete(tmp,0)
        k-=x//(A-B)+(x%(A-B)>0)
"""
        
    
N,A,B=list(map(int,input().split()))
arr=[]

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

max_=max(arr)//B+1
min_=min(arr)//A

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    sum_=0
    for x in arr:
        if x<=0:
            continue
        sum_+=math.ceil((x-mid*B)/d)
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)

Submission status: Wrong Answer

Solution code:
import math
"""
def search(min_,max_,A,B,arr):
#    print(min_,max_)
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=arr-mid*B
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=map(lambda x:math.ceil(x/(A-B)),tmp)
    sum_=sum(list(tmp))
    if sum_<=mid:
        return search(min_,mid,A,B,arr)
    else:
        return search(mid+1,max_,A,B,arr)

    while True:
        if k<0:
            if mid==min_:
                return max_
            else:
                #failure
                return search(mid,max_,A,B,arr[:L])
        elif len(tmp)==0:
            #success
            return search(min_,mid,A,B,arr)
        x=-tmp[0]
        tmp=np.delete(tmp,0)
        k-=x//(A-B)+(x%(A-B)>0)
"""
        
    
N,A,B=list(map(int,input().split()))
arr=[]

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

max_=max(arr)//B+1
min_=min(arr)//A

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    sum_=0
    for x in arr:
        sum_+=min(0,math.ceil((x-mid*B)/d))
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)