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
"""
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_+=math.ceil((x-mid*B)/d)
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(max_)

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_+=math.ceil((x-mid*B)/d)
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(int(min_))

Submission status: Wrong Answer

Solution code:
import numpy as np
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)
min_=1

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    sum_=0
    for x in arr:
        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):
    h=int(input())
    arr.append(h)

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_+=math.ceil((x-mid*B)/d)
    
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)

Submission status: Wrong Answer

Solution code:
import numpy as np
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):
    h=int(input())
    arr.append(h)
arr=sorted(arr,reverse=True)
arr=np.array(arr)

max_=arr[0]//B+1
min_=arr[-1]//A

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def search(min_,max_,A,B,arr):
    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=tmp[tmp>0]
    
    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):
    h=int(input())
    arr.append(h)
arr=sorted(arr)
arr=np.array(arr)

max_=arr[0]//B+1
min_=arr[-1]//A

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def search(min_,max_,A,B,arr):
    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=tmp[tmp>0]
    
    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):
    h=int(input())
    arr.append(h)
arr=sorted(arr)
arr=np.array(arr)

max_=arr[0]//B+1
min_=arr[0]//A

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def search(min_,max_,A,B,arr):
    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=tmp[tmp<0]
    
    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):
    h=int(input())
    arr.append(h)
arr=sorted(arr)
arr=np.array(arr)

max_=arr[0]//B+1
min_=arr[0]//A

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def search(min_,max_,A,B,arr):
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=arr+mid*B
    k=mid
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=tmp[tmp<0]
    
    tmp=map(lambda x:math.ceil(-x/(A-B)),tmp)
    sum_=sum(list(tmp))
    if sum_<=k:
        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=[]
sum_=0

for i in range(N):
    h=int(input())
    arr.append(-h)
    sum_+=h
arr=sorted(arr)
arr=np.array(arr)

max_=-arr[0]//B
min_=arr[0]//A

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def search(min_,max_,A,B,arr):
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=np.copy(arr)
    tmp+=mid*B
    k=mid
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=tmp[tmp<0]
    
    tmp=map(lambda x:-x//(A-B)+(-x%(A-B)>0),tmp)
    sum_=sum(list(tmp))
    if sum_<=k:
        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=[]
sum_=0

for i in range(N):
    h=int(input())
    arr.append(-h)
    sum_+=h
arr=sorted(arr)
arr=np.array(arr)

max_=-arr[0]//B
min_=sum_//(A+(N-1)*B)

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

# 再帰
def solve_rec(n, a, b, h_lst, ans_min, ans_max):
    if ans_min == ans_max:
        return ans_min

    if ans_min > ans_max:
        return -1

    pivot = (ans_min + ans_max) // 2
    # print("try: {}".format(pivot))
    is_beatable = beatable(a, b, h_lst, pivot)

    if is_beatable:
        # print("beatable: {} {}".format(ans_min, ans_max))
        return solve_rec(n, a, b, h_lst, ans_min, pivot)
    else:
        # print("not beatable: {} {}".format(ans_min, ans_max))
        return solve_rec(n, a, b, h_lst, pivot+1, ans_max)

def beatable(a, b, h_lst, pivot):
    # まずBずつ削る
    living = [ h - b * pivot for h in h_lst if h > b * pivot ]
    # print(living)

    # 生き残ったものを1回ずつ(A-B)ダメージずつ与えていくときに、必要な回数
    c = sum([ math.ceil(1.0 * h / (a-b)) for h in living ])
    
    return c <= pivot

def solve(n, a, b, h_lst):
    h_max = max(h_lst)
    ans_min = 0
    ans_max = h_max // b

    return solve_rec(n, a, b, h_lst, ans_min, ans_max)

def main():
    line = sys.stdin.readline()
    lst = line.split()
    n = int(lst[0])
    a = int(lst[1])
    b = int(lst[2])

    h_lst = []
    for i in range(n):
        line = sys.stdin.readline()
        h = int(line)
        h_lst.append(h)
        

    ans = solve(n, a, b, h_lst)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def search(min_,max_,A,B,arr):
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=np.copy(arr)
    tmp+=mid*B
    k=mid
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=tmp[tmp<0]
    
    tmp=map(lambda x:-x//(A-B)+(-x%(A-B)>0),tmp)
    sum_=sum(list(tmp))
    if sum_<=k:
        return search(min_,mid,A,B,arr)
    elif mid==min_:
        return max_
    else:
        return search(mid,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=[]
sum_=0

for i in range(N):
    h=int(input())
    arr.append(-h)
    sum_+=h
arr=sorted(arr)
arr=np.array(arr)

max_=-arr[0]//B
min_=sum_//(A+(N-1)*B)

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def search(min_,max_,A,B,arr):
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=np.copy(arr)
    tmp+=mid*B
    k=mid
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=tmp[tmp<0]
    L=len(tmp)
    
    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=[]
sum_=0

for i in range(N):
    h=int(input())
    arr.append(-h)
    sum_+=h
arr=sorted(arr)
arr=np.array(arr)

max_=-arr[0]//B
min_=sum_//(A+(N-1)*B)

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def search(min_,max_,A,B,arr):
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=arr[:]
    tmp+=mid*B
    k=mid
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=tmp[tmp<0]
    L=len(tmp)
    
    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=[]
sum_=0

for i in range(N):
    h=int(input())
    arr.append(-h)
    sum_+=h
arr=sorted(arr)
arr=np.array(arr)

max_=-arr[0]//B
min_=sum_//(A+(N-1)*B)

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def search(min_,max_,A,B,arr):
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=np.array(arr)
    tmp+=mid*B
    k=mid
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=list(tmp[tmp<0])
    L=len(tmp)
    
    while True:
        x=-tmp.pop()
        k-=x//(A-B)+(x%(A-B)>0)
        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)
            
        
    
N,A,B=list(map(int,input().split()))
arr=[]
sum_=0

for i in range(N):
    h=int(input())
    arr.append(-h)
    sum_+=h
arr=sorted(arr)
arr=np.array(arr)

max_=-arr[0]//B
min_=sum_//(A+(N-1)*B)

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def search(min_,max_,A,B,arr):
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=np.array(arr)
    tmp+=mid*B
    k=mid
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=list(tmp[tmp<0])
    
    while True:
        x=-tmp.pop()
        k-=x//(A-B)+(x%(A-B)>0)
        if k<0:
            if mid==min_:
                return max_
            else:
                return search(mid,max_,A,B,arr)
        elif len(tmp)==0:
            return search(min_,mid,A,B,arr)
            
        
    
N,A,B=list(map(int,input().split()))
arr=[]
sum_=0

for i in range(N):
    h=int(input())
    arr.append(-h)
    sum_+=h
arr=sorted(arr)
arr=np.array(arr)

max_=-arr[0]//B
min_=sum_//(A+(N-1)*B)

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
def search(min_,max_,A,B,arr):
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=np.array(arr)
    tmp+=mid*B
    k=mid
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=list(tmp[tmp<0])
    
    while True:
        x=-tmp.pop()
        k-=x//(A-B)+(x%(A-B)>0)
        if k<0:
            if mid==min_:
                return max_
            else:
                return search(mid,max_,A,B,arr)
        elif len(tmp)==0:
            return search(min_,mid,A,B,arr)
            
        
    
N,A,B=list(map(int,input().split()))
arr=[]

for i in range(N):
    h=int(input())
    arr.append(-h)
arr=sorted(arr)
arr=np.array(arr)

max_=-arr[0]//B
min_=1

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def search(min_,max_,A,B,arr):
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=np.array(arr)
    tmp+=mid*B
    k=mid
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=list(tmp[tmp<0])
    
    while k!=0:
        x=-tmp.pop()
        k-=x//(A-B)+(x%(A-B)>0)
        if k<0:
            if mid==min_:
                return max_
            else:
                return search(mid,max_,A,B,arr)
        elif len(tmp)==0:
            return search(min_,mid,A,B,arr)
            
            
        
    
N,A,B=list(map(int,input().split()))
arr=[]

for i in range(N):
    h=int(input())
    arr.append(-h)
arr=sorted(arr)
arr=np.array(arr)

max_=-arr[0]//B
min_=1

ans=search(min_,max_,A,B,arr)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import heapq

N,A,B=list(map(int,input().split()))
sum_=0
arr=[]

for i in range(N):
    h=int(input())
    sum_+=h
    arr.append(h)
arr=sorted(arr,reverse=True)
arr=np.array(arr)

min_=sum_//(A+B*(len(arr)-1))
ans=min_

arr-=min_*B
arr=arr[arr>0]
for i in range(len(arr)):
    tmp=arr[i]//(A-B)
    if min_<tmp:
        tmp=min_
        min_=0
        arr[i]-=tmp*(A-B)
        break
    else:
        min_-=tmp
        arr[i]-=tmp*(A-B)
arr=list(-arr[arr>0])
heapq.heapify(arr)

cnt=0
while len(arr)>0:
    x=heapq.heappop(arr)
    x+=B*cnt
    if x>=0:
        continue
    x+=(A-B)
    if x<-B:
        heapq.heappush(arr,x)
    
    if min_>0:
        min_-=1
    else:
        cnt+=1
print(ans+cnt)

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 = A - B
ng, ok = 0, 10 ** 9 + 1
while abs(ok - ng) > 1:
    X = (ng + ok) // 2
    H_damaged = [h - B * X for h in H]
    need = sum([ceil(h / A) for h in H_damaged])

    if need <= X:
        ok = X
    else:
        ng = X

print(ok)

Submission status: Wrong Answer

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

left = 0
right = max(h)
now = right//2
while left+1 < right:
    temp = 0
    for i in range(n):
        if (h[i]-b*now)%(a-b) == 0:
            temp += (h[i]-b*now)//(a-b)
        else:
            temp += (h[i]-b*now)//(a-b) + 1
    if temp <= now:
        right = now
        now = (right+left)//2
    else:
        left = now
        now = (right+left)//2

for i in range(n):
    if (h[i]-b*left)%(a-b) == 0:
        temp += (h[i]-b*left)//(a-b)
    else:
        temp += (h[i]-b*left)//(a-b) + 1
if temp <= left:
    print(left)
else:
    print(right)

Submission status: Wrong Answer

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

left = 0
right = max(h)//b+1
now = right//2
while left+1 < right:
    temp = 0
    for i in range(n):
        if (h[i]-b*now)%(a-b) == 0:
            temp += (h[i]-b*now)//(a-b)
        else:
            temp += (h[i]-b*now)//(a-b) + 1
    if temp <= now:
        right = now
        now = (right+left)//2
    else:
        left = now
        now = (right+left)//2

for i in range(n):
    if (h[i]-b*left)%(a-b) == 0:
        temp += (h[i]-b*left)//(a-b)
    else:
        temp += (h[i]-b*left)//(a-b) + 1
if temp <= left:
    print(left)
else:
    print(right)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] >= B * T:
            num += math.ceil((H[i] - B * T - 1) / (A - B))
    return T >= num


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

print(mid)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] >= B * T:
            num += math.ceil((H[i] - B * T) / (A - B))
    return T >= num


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

print(mid)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] >= B * T:
            num += math.ceil((H[i] - B * T) / (A - B))
    return T >= num


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

print(mid)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
H = [int(input()) for i in range(N)]
H.sort()
from math import ceil
def KnockOut(t):
    base = B*t
    for i in range(N):
        h = H[i]
        h -= base
        if h > 0:
            t -= ceil(h/(A-B))
        if t < 0:
            return False
    return True
l = 0
r = ceil(sum(H)/(N*B))
while l != r-1:
    t = int((l+r)/2)
    if KnockOut(t):
        r = t
    else:
        l = t
print(r)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
H = [int(input()) for i in range(N)]
H.sort()
from math import ceil
def KnockOut(t):
    base = B*t
    res = 0
    for i in range(N):
        h = H[i]
        h -= base
        if h > 0:
            res += ceil(h/(A-B))
    return res <= t
l = 1
r = ceil(sum(H)/(N*B))
while l != r-1:
    t = int((l+r)/2)
    if KnockOut(t):
        r = t
    else:
        l = t
print(r)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
H = [int(input()) for i in range(N)]
H.sort()
import bisect
def KnockOut(t):
    base = B*t
    res = 0
    j = bisect.bisect(H,base)
    for i in range(j,N):
        h = H[i]
        h -= base
        if h > 0:
            res += h//(A-B)+min(h%(A-B),1)
    return res <= t
from math import ceil
l = 1
r = ceil(sum(H)/(N*B))
while l != r-1:
    t = int((l+r)/2)
    if KnockOut(t):
        r = t
    else:
        l = t
print(r)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
H = [int(input()) for i in range(N)]
H.sort()
def KnockOut(t):
    base = B*t
    res = 0
    for i in range(N):
        h = H[i]
        h -= base
        if h > 0:
            res += h//(A-B)+min(h%(A-B),1)
    return res <= t
from math import ceil
l = 1
r = ceil(sum(H)/(N*B))
while l != r-1:
    t = int((l+r)/2)
    if KnockOut(t):
        r = t
    else:
        l = t
print(r)

Submission status: Wrong Answer

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

low, high = 1, 1 + 10**9
while high - low > 1:
    mid = (low + high)//2
    count = 0
    for i in range(N):
        if H[i] - (B * mid) > 0:
            if (H[i] - (B * mid))%(A-B) == 0:
                count += (H[i] - (B * mid))//(A-B)
            else:
                count += (H[i] - (B * mid))//(A-B) + 1
    if count > mid:
        low = mid
    else:
        high = mid
print(high)

Submission status: Wrong Answer

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

left = 0
right = 10**12
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    count = 0
    for i in range(n):
        if h[i] - mid * b > 0:
            count += (h[i] - mid * b) // (a - b) + 1
    if mid - count >= 0:
        right = mid
    else:
        left = mid
print(mid)

Submission status: Wrong Answer

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

left = 0
right = 10**9
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    count = 0
    for i in range(n):
        if h[i] - mid * b > 0:
            count += (h[i] - mid * b) // (a - b) + 1
    if mid - count >= 0:
        right = mid
    else:
        left = mid
print(mid)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
lis = [int(input()) for i in range(n)]
more = a-b

def tansaku(x):
  cou = 0
  normal = b * x
  for hp in lis:
    r = hp -normal
    if r <= 0:continue
    cou += r // more
    
    if r % more != 0:
      cou += 1
  return cou <= x

left = 1
right = max(lis)
while right - left > 1:
  mid = (right + left)/2
  if tansaku(mid):
    right = mid
  else:
    left = mid
print(right)

Submission status: Wrong Answer

Solution code:
N, A, B = map( int, input().split())
H = [0]*N
hmax = 0
for i in range(N):
    h = int( input())
    H[i] = h
hmax = max(H)
L = 0
R = hmax//B + 1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        r = H[i] - now*B
        if r > 0:
            need += -(-r)//add
    if need <= now:#うまくいくとき
        R = now
    else:#うまくいかないとき
        L = now+1#うまく行かないので+1している．これがないと無限ループが発生する。
print(L)

Submission status: Wrong Answer

Solution code:
from math import ceil
N, A, B = map(int, input().split())
H = []

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

# judge to win with X times explosions
def judge(X,Hlist):
  cnt = 0
  for i in range(N):
    if Hlist[i] - (X * B) > 0:
      cnt += ceil((Hlist[i] - (X * B)) / (A-B))
  
  #print("judge",cnt,X)
  if cnt <= X:
    return True
  else:
    return False

# binary search for X
left = 1
right = ceil(max(H) // B)

while left < right:
  mid = (left + right) // 2
  fl = judge(mid,H)
  #print("bsearch", mid, fl)
  if fl:
    right = mid
  else:
    left = mid + 1
    
print(right)

Submission status: Wrong Answer

Solution code:
from math import ceil
N, A, B = map(int, input().split())
H = []

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

# judge to win with X times explosions
def judge(X,Hlist):
  cnt = 0
  for i in range(N):
    if Hlist[i] - (X * B) > 0:
      cnt += ceil((Hlist[i] - (X * B)) // (A-B))
  
  #print("judge",cnt,X)
  if cnt <= X:
    return True
  else:
    return False

# binary search for X
left = 1
right = ceil(max(H) // B)

while left < right:
  mid = (left + right) // 2
  fl = judge(mid,H)
  #print("bsearch", mid, fl)
  if fl:
    right = mid
  else:
    left = mid + 1
    
print(right)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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


def is_OK(x):
    cnt = 0
    for hi in h:
        hi -= B * x
        if hi > 0:
            if hi % (A - B) == 0:
                cnt += hi // (A - B)
            else:
                cnt += hi // (A - B) + 1
    return cnt <= x


left = 0
right = sum(h) // A + 1
while right - left > 1:
    mid = (left + right) // 2
    if is_OK(mid):
        right = mid
    else:
        left = mid
print(right)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,a,b = map(int,raw_input().split())

arr = []
for i in range(n):
	arr.append(int(input()))

def enough(i):
	t = i
	for j in arr:
		t -= max(0,np.ceil((j-i*b*1.0)/(a-b)))
		if t < 0:
			return False

	return True


l = 1
r = 10**9

while r-l > 1:
	c = l+(r-l)/2
	if enough(c) :
		r = c
	else :
		l = c

print r

Submission status: Wrong Answer

Solution code:
import numpy as np
n,a,b = map(int,raw_input().split())

arr = []
for i in range(n):
	arr.append(int(input()))

def enough(i):
	t = i
	for j in arr:
		t -= max(0,np.ceil((j-i*b*1.0)/(a-b)))
		if t < 0:
			return False

	return True


l = 1
r = 10**9

while r-l > 1:
	c = l+(r-l)/2
	if enough(c) :
		r = c
	else :
		l = c+1

print r