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: Runtime Error

Solution code:
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    N,A,B = map(int,input().split())
    h = [int(input()) for i in range(N)]
    h.sort(reverse = True)
    privalue = h[0]
    secvalue = h[1]
    ans = 0
    while secvalue > 0:
        privalue,secvalue = max(privalue-A,secvalue-B),min(privalue-A,secvalue-B)
        ans += 1
    ans += (privalue//A+1 if privalue % A != 0 else privalue//A)
    print(ans)
    

if __name__ == "__main__":
    main() #endline===============================================

Submission status: Runtime Error

Solution code:
### reference
import numpy as np
N, A, B = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
H = np.array(h)

### n回以下の攻撃で、全滅させられるかどうか。
def test(n):
    x = H - n*B
    x[x<0] = 0
    　　　　#np.ceilが結局追加攻撃しなければならないそれぞれのモンスターの攻撃階数
    return np.ceil(x/(A-B)).sum() <= n

## left, right←攻撃階数
left = 0
right = 10**9

while right - left > 1:
    mid = (left + right)//2
    if test(mid):
        right = mid
    else:
        left = mid
ans = right
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n, a, b = map(int, input().split())
hlist = np.array([int(input()) for _ in range(n)])

def kill(k):
    tmp = hlist - k*b
    tmp[tmp<0] = 0
    if np.ceil(tmp/(a-b)).sum() <= n:
        return True
    else:
        return False

left = 0
right = 10*9
while right - left > 1:
    mid = (right + left)//2
    if kill(mid):
        right = mid
    else:
        left = mid
ans = right
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n, a, b = map(int, input().split())
hlist = np.array([int(input()) for _ in range(n)])

def kill(k):
    tmp = hlist - k*b
    tmp[tmp<0] = 0
    if np.ceil(tmp//(a-b)).sum() <= n:
        return True
    else:
        return False

left = 0
right = 10*9
while right - left > 1:
    mid = (right - left)//2
    if kill(mid):
        right = mid
    else:
        left = mid
ans = right
print(ans)

Submission status: Runtime Error

Solution code:
def calc(n):
    damage = (b * n)
    d = [max(dd - damage, 0) for dd in h]
    a_num = 0
    for i in range(len(d)):
        a_num += max(0, 1 + (d[i]-1) // (a - b))
    if a_num <= n:
        return True
    return False

n, a, b = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
ans = 0
h.sort()

left = 0
right = (h[-1] + 1) // (b)

while (right - left) > 1:
    middle = (left + right) // 2
    if calc(middle):
        right = middle
    else:
        left = middle
if calc(middle):
    print(middle)
else:
    print(middle + 1)

Submission status: Runtime Error

Solution code:
def calc(n):
    damage = (b * n)
    d = [max(dd - damage, 0) for dd in h]
    a_num = 0
    for i in range(len(d)):
        a_num += max(0, 1 + (d[i]-1) // (a - b))
    if a_num <= n:
        return True
    return False

n, a, b = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
ans = 0
h.sort()

left = 0
right = (h[-1] + 1) // (b)

while (right - left) > 1:
    middle = (left + right) // 2
    if calc(middle):
        right = middle
    else:
        left = middle
print(middle)

Submission status: Runtime Error

Solution code:
def calc(n):
    damage = (b * n)
    d = [max(dd - damage, 0) for dd in h]
    a_num = 0
    for i in range(len(d)):
        a_num += max(0, 1 + (d[i]-1) // (a - b))
    if a_num <= n:
        return True
    return False

n, a, b = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
ans = 0
h.sort()

left = 1
right = (h[-1] + 1) // (b)

while (right - left) > 1:
    middle = (left + right) // 2
    if calc(middle):
        right = middle
    else:
        left = middle
print(middle)

Submission status: Runtime Error

Solution code:
import copy
def calc(n):
    d = copy.deepcopy(h)
    d = [dd - (b * n) for dd in d if (dd - (b*n)) > 0]
    a_num = sum([dd // (a - b) if (dd % (a - b) == 0) else (dd // (a - b)) + 1 for dd in d])
    if a_num <= n:
        return True
    return False

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


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

while right - left > 1:
    middle = (left + right) // 2
    if calc(middle):
        right = middle
    else:
        left = middle
print(middle)

Submission status: Runtime Error

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def check(h, x, A, B):
    h = [ hi - B * x for hi in h ]
    c = 0
    for hi in h:
        if hi <= 0:
            continue
        c += math.ceil(hi/(A-B))
    return c <= x

def main():
    N, A, B = l_inpl()
    h = line_inpl(N)

    l, r = 0, max(h)//B + 1000
    while l + 1 != r:
        mid = (l+r) // 2
        if check(h, mid, A, B):
            r = mid
        else:
            l = mid
    
    print(r)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import heapq
#n=int(input())
n,a,b=map(int,input().split())
ans=chk=0
d=[]
for i in range(n):
    x=int(input())
    heapq.heappush(d,-x)
c=a-b
while 1:
#for i in range(5):
    t=heapq.heappop(d)
    if t+chk>=0: break
    ans+=1
    p=(abs(t-d[0])+c-1)//c
    p=max(1,p)
    t+=c*p
    chk+=b*p
    heapq.heappush(d,t)
print(ans)

Submission status: Runtime Error

Solution code:
from copy import deepcopy
def main():
    n,a,b,*h=map(int,open(0).read().split())
    h=array(h)

    ok=-1
    ng=max(h)//a+10
    
    def judge(t):
        H=deepcopy(h)
        H-=b*t
        H=H[H>0]
        if sum((H-1)//(a-b)+1)<=t:
            return 1
        else:
            return 0
    
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if judge(mid):
            ng=mid
        else:
            ok=mid
    l=ok+1
    print(l)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
n,a,b=map(int,input().split())
h=[]
for i in range(n):
    x=int(input())
    h.append(x)

def check(t):
    c=0
    for i in range(n):
        c+=1+(max(0,h[i]-b*t)-1)//(a-b)
    return t>=c

l=1
r=1+max(h)//b
while r-l>1:
    mid=(r-l)//2+l
    if check(mid):
        r=mid
    else:
        l=mid
ans=l
if check(r):
    #ans=r
print(ans)

Submission status: Runtime Error

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

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

    M = roof(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(int(ans(n,a,b,h))

Submission status: Runtime Error

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 a[0]>0:
	if a[0]>=a[1]:
		a[0]-=C
		map(lambda x: x-B,a)
		n += 1
	else:
		a[1]-=C
		map(lambda x: x-B,a)
		n += 1
print n

Submission status: Runtime Error

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 a[0]>0:
	if a[0]>=a[1]:
		a[0]-=C
		map(lambda x: x-B,a)
		n += 1
	else:
		a[1]-=C
		map(lambda x: x-B,a)
		n += 1
print n

Submission status: Runtime Error

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
def cri(p):
    if p > 0:
        return p
while True:
    for j in range(n):
        X += cri(math.ceil((h[j] - t * b) / (a - b)))
    if X <= t:
        for j in range(n):
            Y += cri(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: Runtime Error

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

print(min_)

Submission status: Runtime Error

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

while min_!=max_:
    mid=(max_+min_)//2
    
    tmp=arr-mid*B
    tmp=map(lambda x:math.ceil(x/(A-B)),tmp)
    sum_=sum(list(tmp))
    
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

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

print(ans)

Submission status: Runtime Error

Solution code:
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

while min_!=max_:
    mid=(max_+min_)//2
    
    tmp=arr-mid*B
    tmp=map(lambda x:math.ceil(x/(A-B)),tmp)
    sum_=sum(list(tmp))
    
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

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

print(ans)

Submission status: Runtime Error

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:
        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: Runtime Error

Solution code:
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: Runtime Error

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
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid):
        right = mid
    else:
        left = mid

print(mid)

Submission status: Runtime Error

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 * i:
            num += math.ceil((H[i] - B * T) / (A - B))
    return T > num


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

print(mid)

Submission status: Runtime Error

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(j,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: Runtime Error

Solution code:
n,a,b = map(int,input().split())
h = list(int(input()) for i in range(n))
h.sort(reverse=True)
cnt = 0
while h[0]>0:
    cnt +=1
    h[0] -= a
    for i in range(1,n):
        h[i] -= b
    if h[0] < h[1]:
        h[0],h[1] = h[1],h[0]

print(cnt)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
h = list(int(input()) for i in range(n))
h.sort(reverse=True)
cnt = 0
while h[0]>0:
    cnt +=1
    h[i] -= a
    for j in range(i+1,n):
        h[j] -= b
    h.sort(reverse=True)

print(cnt)

Submission status: Runtime Error

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 cnt <= t

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: Runtime Error

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 % ab != 0:
      cou += 1
  return cnt <= t

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: Runtime Error

Solution code:
N, M = map(int, input().split())

def bf(links, n, st=1):
    inf = float('inf')
    dj = [inf] * (n + 1)
    dj[st] = 0
    for i in range(N):
        updated = False
        for link in links:
            fn, tn, lc = link
            lc *= -1
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                updated = True
        if not updated: break
    else:
        pn = dj[-1]
        for i in range(N):
            updated = False
            for link in links:
                fn, tn, lc = link
                lc *= -1
                if dj[fn] + lc < dj[tn]:
                    dj[tn] = dj[fn] + lc
                    updated = True
            if not updated: break
        return inf if pn != dj[-1] else -dj[-1]
    return -dj[-1]

links = []
for _ in range(M):
    links.append([int(x) for x in input().split()])

print(bf(links, N, 1))

Submission status: Runtime Error

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

import bisect, math
def f(ll, ul):
    if ul - ll == 1: return ll
    cur = (ll + ul) // 2
    r = H[bisect.bisect_right(H, B * cur):]
    p = sum(math.ceil((x - B * cur) / (A - B)) for x in r)

    if p == cur:
        return cur
    elif p < cur:
        return f(ll, cur)
    else:
        return f(cur + 1, ul)

print(f(0, math.ceil((H[-1]) / B) + 1))

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
h = []
for i in range(n):
	x = int(input())
	h.append(x)
count = 0
while max(h) > 0:
	if max(h) % a == 0:
		hit = int(max(h)/a)
	else:
		hit = int(max(h)/a)+1
	h[list.index(max(h))] = 0
	h = list(map(lambda x: x-(b*hit),h)
	count += hit	
print hit

Submission status: Runtime Error

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

def enough(t):
    count = 0
    for hp in h:
        count += ceil(max(0, hp - b*t) / (a-b))
    if(count <= t):
        return True
    else:
        return False


high = ceil(max(h)/b)
low = 0
while(high - low > 1):
    mid = (high + low) // 2
    if(enough(mid)):
        high = mid
    else:
        low = mid
print(mid)

Submission status: Runtime Error

Solution code:
# Widespread
n,a,b = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))
    
import math as m

def check(ary, num, a, b):
    bommed = [(hi- b*num) for hi in h if (hi- b*num)>0]
    acnt = sum([m.ceil(hi/(a-b)) for hi in bommed])
    if acnt > num:
        return "NO"
    else:
        return "YES"

imin = 1
imax = m.ceil(max(nh)/a)

while ( imax > imin+1 ):
    imid = imin + (imax-imin)//2
    if ( check(h, imid, imin, imax)=="YES" ):
        imax = imid
    else:
        imin = imid
print(imax)

Submission status: Runtime Error

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


# やり直し
import math as m

def check(ary, num, a, b):
    bommed = [(hi- b*num) for hi in h if (hi- b*num)>0]
    acnt = sum([m.ceil(hi/(a-b)) for hi in bommed])
    if acnt > num:
        return "NO"
    else:
        return "YES"

imin = 1
imax = m.ceil(max(nh)/a)

while ( imax > imin+1 ):
    imid = imin + (imax-imin)//2
    if ( check(h, imid, imin, imax)=="YES" ):
        imax = imid
    else:
        imin = imid
print(imax)

Submission status: Runtime Error

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

# やり直し
import math as m

def check(ary, num, a, b):
    bommed = [(hi- b*num) for hi in h if (hi- b*num)>0]
    acnt = sum([m.ceil(hi/(a-b)) for hi in bommed])
    if acnt > num:
        return "NO"
    else:
        return "YES"

imin = 1
imax = m.ceil(max(nh)/a)

while ( imax > imin+1 ):
    imid = imin + (imax-imin)//2
    if ( check(h, imid, imin, imax)=="YES" ):
        imax = imid
    else:
        imin = imid
print(imax)

Submission status: Runtime Error

Solution code:
import numpy as np
import math

N,A,B = map(int, input().split())
h = np.zeros(N)

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

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while (mx-mn) > 1 :
    if now >= sum(np.ceil(tmp[tmp>0]/(A-B))) :
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(mx))

Submission status: Runtime Error

Solution code:
import numpy as np
import math

N,A,B = map(int, input().split())
h = np.zeros(N)

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

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while (mx-mn) <= 1 :
    if now >= sum(np.ceil(tmp[tmp>0]/(A-B))) :
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(mx))

Submission status: Runtime Error

Solution code:
I'm Yata Ryuichi.

Submission status: Runtime Error

Solution code:
    import math
     
    n, a, b = map(int, input().split(" "))
     
    h = []
    for i in range(n):
        h.append(int(input()))
     
    h.sort(reverse=True)
     
     
    def check(count_target, h, a, b):
        count = 0
     
        for i in h:
            if i >= count_target * b:
                count += math.ceil((i - count_target * b) / (a - b))
        return count_target - count
     
     
    l = 1
    r = math.ceil(h[0] / b)
     
     
    while r - l > 1:
        mid = math.floor(l + (r - l) / 2)
     
        if check(mid, h, a, b) < 0:
            l = mid
        else:
            r = mid
     
     
    if check(l, h, a, b) < 0:
        print(int(r))
    else:
        print(int(l))

Submission status: Runtime Error

Solution code:
n,a,b = map(int, input().split())
nums = [0 for i in range(n)]
for i in range(n):
    nums[i] = int(input())
nums = sorted(nums, reverse = True)
count = 0
while nums[0]>0:
    nums[0]=nums[0]-a
    for i in range(1,n):
        nums[i]=nums[i]-b
    nums = sorted(num, reverse = True)
    count += 1
print(str(count))

Submission status: Runtime Error

Solution code:
n,a,b = [int(x) for x in input().split()]

monsters_hp = sorted([int(input()) for _ in range(n)])

use_magic_times = 0
any_monster_alive = True

while any_monster_alive:
	for i in range(n-1):
		monsters_hp[i] -= a
	monsters_hp[n] -= b
	monsters_hp.sort()
	use_magic_times += 1
	if monsters_hp[n] <= 0:
		any_monster_alive = False

print(use_magic_times)

Submission status: Runtime Error

Solution code:
class Monster():
	def __init__(self, hp, A, B):
		self.hp = hp
		self.live = 1
		self.center = A
		self.side = B
	
	def is_die(self):
		if self.hp <= 0:
			self.live = 0
	
	def center_bombed(self):
		self.hp -= self.center
		self.is_die()
	
	def side_bombed(self):
		self.hp -= self.side
		self.is_die()
	
N, A, B =[int(i) for i in input().split()]
monsters = []
counter = 0
for i in range(N):
	h = int(input())
	monsters.append(Monster(h, A, B))

while True:
	NN = len(monsters)
	hp_of_monsters = [m.hp for m in monsters]
	MAX = max(hp_of_monsters)
	number = hp_of_monsters.index(MAX)
	for i in range(NN):
		if i == number:
			monsters[i].center_bombed()
		else:
			monsters[i].side_bombed()
	counter += 1
	monsters = [m for m in monsters if m.live == 1]
	if len(monsters) == 0:
		print(counter)

Submission status: Runtime Error

Solution code:
class Monster():
	def __init__(self, hp, A, B):
		self.hp = hp
		self.live = 1
		self.center = A
		self.side = B
	
	def is_die(self):
		if self.hp <= 0:
			self.live = 0
	
	def center_bombed(self):
		self.hp -= self.center
		self.is_die()
	
	def side_bombed(self):
		self.hp -= self.side
		self.is_die()
	
N, A, B =[int(i) for i in input().split()]
monsters = []
counter = 0
for i in range(N):
	h = int(input())
	monsters.append(Monster(h, A, B))

while True:
	NN = len(monsters)
	hp_of_monsters = [m.hp for m in monsters]
	MAX = max(hp_of_monsters)
	number = hp_of_monsters.index(MAX)
	for i in range(NN):
		if i == number:
			monsters[i].center_bombed()
		else:
			monsters[i].side_bombed()
	counter += 1
	monsters = [m for m in monsters if m.live == 1]
	if len(monsters) == 0:
		print(counter)
		return

Submission status: Runtime Error

Solution code:
class Monster():
	def __init__(self, hp, A, B):
		self.hp = hp
		self.live = 1
		self.center = A
		self.side = B
	
	def is_die(self):
		if self.hp <= 0:
			self.live = 0
	
	def center_bombed(self):
		self.hp -= self.center
		self.is_die()
	
	def side_bombed(self):
		self.hp -= self.side
		self.is_die()
	
N, A, B =[int(i) for i in input().split()]
monsters = []
counter = 0
for i in range(N):
	h = int(input())
	monsters.append(Monster(h, A, B))

while True:
	NN = len(monsters)
	hp_of_monsters = [m.hp for m in monsters]
	MAX = max(hp_of_monsters)
	number = hp_of_monsters.index(MAX)
	for i in range NN:
		if i == number:
			monsters[i].center_bombed()
		else:
			monsters[i].side_bombed()
	counter += 1
	monsters = [m for m in monsters if m.live == 1]
	if len(monsters) == 0:
		print(counter)
		return

Submission status: Runtime Error

Solution code:
#coding=UTF-8
#ぎりぎり間に合わないので少しがんばってみる
def turn_check(zikan):
    nokori_naka=zikan
    for idx in range(0,N,1):
        rem_hp=kirei_HP[idx]-around*zikan
        if rem_hp > 0:
        
            nokori_naka=nokori_naka-(rem_hp//dmgsa + (0 if rem_hp%dmgsa==0 else 1))
            if nokori_naka < 0:
                return False
        else: #以降も周辺攻撃のみで倒せる
            return True

    return True


mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
A=int(hyo[1])
B=int(hyo[2])

HP=[]
for idx in range(0,N,1):
    HP.append(int(input()))

kirei_HP=sorted(HP,reverse=True)
kagen=kirei_HP[0]// A + 1

tansaku=kagen//2
dmgsa=A-B
while True:
    if turn_check(tansaku):
        kagen=tansaku
        tansaku=kagen//2
    else:
        if tansaku + 1 == kagen: #丁度境目を見付けたら
            break
        else:
            tansaku=(tansaku+kagen)//2

print(kagen)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

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

while H:
    index = max(enumerate(H), key=lambda x: x[1])[0]
    H[index] -= A
    H = [H[x]-B for x in range(len(H)) if x!=index]
    I = [x for x in range(len(H)) if H[x] <= 0]
    [H.pop(x) for x in I]
    c += 1

print(c)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
N, A, B = [int(_) for _ in input().split()]
H = [int(input()) for _ in range(N)]
H = np.sort(H)[::-1]
H = np.delete(H,np.where(H<=int(math.ceil(H[0]/A))*B))
attack = np.ones(len(H)).astype(np.int64)
attack *= B
attack[0] = A
count = 0
p = int(H[0]/A)
order = 0
while p>=10:
    p /= 10
    order+=1
while H[0]>0:
    if H[0]/(A*10**(order)) > 1:
        H -= attack*10**(order)
        H = np.sort(H)[::-1]
        count += 10**(order)
    else:
        order -= 1
        if order<0:
            break
        H -= attack*10**(order)
        H = np.sort(H)[::-1]
        count += 10**(order)
while H[0]>0:
    H -= attack
    H = np.sort(H)[::-1]
    count += 1
print (count)

Submission status: Runtime Error

Solution code:
#coding: utf-8

line = input().strip()
N = int(line[0])
A = int(line[2])
B = int(line[4])
monster = [int(input()) for i in range(N)]

times = 0
while len(monster) > 0:
    n = monster.index(max(monster)) #一番体力が大きい魔物のインデックス
    monster[n] = monster[n] - A
    if monster[n] < 1:
        monster[n] = 0

    for i, x in enumerate(monster):
        if i != n:
            monster[i] = monster[i] - B
            if monster[i] < 1:
                monster[i] = 0
    for i in monster:
        if i == 0:
            monster.remove(0)

    times = times + 1

print (times-1)