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: Accepted

Solution code:
from math import ceil

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

# T回の攻撃で全員倒せるかを判定する関数
def enough(T:int) -> bool:
    normal = B*T   # 通常攻撃でのダメージ
    addit = A-B    # 追加攻撃でのダメージ
    
    cnt = 0        # 追加攻撃の必要回数
    for h in H:
        need_add = ceil((h-normal) / addit)
        if need_add > 0:
            cnt += need_add
        
    return cnt <= T

# enough(T) == True となる最小のTを探す
# lowの更新で終わればhighが答え、highの更新で終わってもhighが答え
def search() -> int:
    low = 0             # 絶対False
    high = 10**9 + 1    # 絶対True
    
    # midがhighでもlowでもない数になるようにする
    while high - low > 1:
        mid = (high + low) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
            
    return high

print(search())

Submission status: Accepted

Solution code:
import math

def solve():
    n, a, b = list(map(int, input().split()))
    h = [int(input()) for _ in range(n)]
    h = sorted(h)

    def is_enough(t):
        t_check = 0
        for hh in h:
            hh -= b*t
            if hh > 0:
                t_check += math.ceil(hh/(a-b))
        if t_check > t: return False
        else: return True

    t_min = 1
    t_max = h[-1]//b+1 # number of spell
    while t_min != t_max-1:
        t_next = (t_min+t_max)//2
        if is_enough(t_next):
            t_max = t_next
        else:
            t_min = t_next
        # print(t_min, t_max)

    if is_enough(t_min): print(t_min)
    else: print(t_max)
    return

solve()

Submission status: Accepted

Solution code:

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(N, A, B, H):
    H.sort(reverse=True)

    def e(t):
        b = B*t
        a = A-B
        for h in H:
            h -= b
            if h > 0:
                t -= int(math.ceil(h/a))
        return t >= 0

    l = 0
    r = max(H)
    while r - l > 1:
        m = (r+l)//2
        if e(m):
            r = m
        else:
            l = m

    return r


def main():
    N, A, B = read_int_n()
    H = [read_int() for _ in range(N)]

    print(slv(N, A, B, H))


if __name__ == '__main__':
    main()

Submission status: Accepted

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: 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 f(ll, cur)
    else:
        return f(cur + 1, ul)

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

Submission status: Accepted

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: 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)))

Submission status: Accepted

Solution code:
import math
n, a, b = map(int,input().split(' '))

h = [ 0 for i in range(n)]

def enough(x):
    cnt=0
    for hi in h:
        if hi>b*x:
            cnt+= math.ceil((hi-b*x)/(a-b))
    return cnt <= x

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

x_max = max(h)
x_min = 0
while(x_max - x_min > 1):
    x_mid = (x_max + x_min)//2
    if(enough(x_mid)):
        x_max = x_mid
    else:
        x_min = x_mid

print(x_max)

Submission status: Accepted

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

ab = A - B


def check(t):
    cnt = 0
    bt = B * t
    for hi in h:
        r = hi - bt
        if r <= 0:
            continue
        cnt += r // ab
        if r % ab:
            cnt += 1
    return cnt <= t


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

Submission status: Accepted

Solution code:
import math
N, A, B = map(int, input().split())
H = [0] * N
H = [int(input()) for i in range(N)]
maxH = max(H)
U = math.ceil(maxH / B)
L = 0
def binsearch(U, L):
  m = (U + L) // 2
  if m == L:
    print(U)
  else:
    if sum([math.ceil(max(h - B * m, 0) / (A - B)) for h in H]) <= m:
      binsearch(m, L)
    else:
      binsearch(U, m)
binsearch(U, L)

Submission status: Accepted

Solution code:
import math

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


def check(t):
    cnt = 0
    ab = A - B
    bt = B * t
    for i in range(N):
        r = (h[i] - bt)
        if r <= 0:
            continue
        cnt += r // ab
        if r % ab:
            cnt += 1
    return cnt <= t


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

Submission status: Accepted

Solution code:
import math

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


def check(t):
    cnt = 0
    ab = A - B
    bt = B * t
    for i in range(N):
        cnt += max(0, math.ceil((h[i] - bt) / ab))
    return cnt <= t


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

Submission status: Accepted

Solution code:
import math

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


def check(t):
    cnt = 0
    bt = B * t
    for i in range(N):
        cnt += max(0, math.ceil((h[i] - bt) / (A - B)))
    return cnt <= t


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

Submission status: Accepted

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

def enough(t):
    cnt = 0
    for h in H:
        # 全体攻撃を受けた残りHP
        rh = h - b * t
        if rh <= 0:
            continue
        cnt += rh//(a-b)
        if rh%(a-b) != 0:
            cnt += 1
    if cnt <= t:
        return True
    else:
        return False

bot = floor(sum(H)/(a+(n-1)*b))
if enough(bot):
    print(bot)
    sys.exit(0)
top = ceil(max(H)/b)
mid = (top+bot)//2
while(top-bot>1):
    if enough(mid):
        top = mid
    else:
        bot = mid
    mid = (top+bot)//2
#print(bot,mid,top)
print(top)

Submission status: Accepted

Solution code:
import math

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


def check(t):
    cnt = 0
    for i in range(N):
        cnt += max(0, math.ceil((h[i] - B * t) / (A - B)))
    return cnt <= t


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

Submission status: Accepted

Solution code:
import math
N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
C = A - B

def judge(t):
    count = 0
    Bt = B * t
    for i in range(N):
        numerator = h[i] - Bt
        count += max(math.ceil(numerator / C), 0)
    return count <= t

left = 0
right = math.ceil(10**9 // B) + 1
mid = (left + right) // 2
while right - left > 1:
    if judge(mid):
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
print(right)

Submission status: Accepted

Solution code:
N, A, B = map(int,input().split())
h = [0 for i in range(N)]
for i in range(N):
	h[i] = int(input())
h = sorted(h)
import math
# N, A, B = 4, 5, 3
# h = [8,7,4,2]
# h = sorted(h,reverse=True)

def enough(T):
	tmp = 0
	for i in range(N):
		if h[i] >= B*T:
			tmp += math.ceil((h[i]-B*T)/(A-B))
	return True if tmp <= T else False

MAX = 10**9
MIN = 0
MID = (MAX+MIN)//2
while MAX > MIN+1:
	if enough(MID) == True:
		MAX = MID
	else:
		MIN = MID
	MID = (MAX+MIN)//2
print(MAX)

Submission status: Accepted

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

def enough(t):
    cnt = 0
    for h in H:
        # 全体攻撃を受けた残りHP
        rh = h - b * t
        if rh <= 0:
            continue
        cnt += rh//(a-b)
        if rh%(a-b) != 0:
            cnt += 1
    if cnt <= t:
        return True
    else:
        return False

bot = 0
top = ceil(max(H)/b)
mid = (top+bot)//2
while(top-bot>1):
    if enough(mid):
        top = mid
    else:
        bot = mid
    mid = (top+bot)//2
#print(bot,mid,top)
print(top)

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

N,A,B = map(int,input().split())
C = A-B
health = [int(input()) for i in range(N)]
health.sort()

def check(Bx):
	Ax = 0
	for h in health:
		if h > Bx*B:
			Ax += math.ceil((h-Bx*B)/C)
	return Ax <= Bx

low = 0
high = health[N-1]//B+1

while True:
	mid = (low+high)//2
	if check(mid):
		high = mid
	else:
		low = mid
	if high - low <= 1:
		break

print(high)

Submission status: Accepted

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

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

# 特定の爆破数で全滅させられるかを判定する関数
def enough(T):
    cnt = 0
    # 各魔物について確認していく
    for i in range(N):
        hp = hN[i]
        # 全体への共通ダメージ分
        hp -= B*T
        # 倒せていなければ追加ダメージを与える
        if hp > 0:
            cnt += (hp-1) // (A-B) +1
    # 追加ダメージに使用した合計爆破数がT回以内かどうか判定
    if cnt <= T:
        return True
    else:
        return False

# 2分探索で最初にTrueになる場所を見つける
# hi = 10 ** 9
# low = 0
# while low+1 < hi:
#     mid = (hi+low) // 2
#     if enough(mid):
#         hi = mid
#     else:
#         low = mid
# print(hi)

hi = 10 ** 9 + 1
low = 0
mid = 10 ** 9 // 2
while low+1 < hi:
    if enough(mid):
        hi = mid
    else:
        low = mid
    mid = (hi+low+1) // 2
print(mid)

Submission status: Accepted

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

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

# 特定の爆破数で全滅させられるかを判定する関数
def enough(T):
    cnt = 0
    # 各魔物について確認していく
    for i in range(N):
        hp = hN[i]
        # 全体への共通ダメージ分
        hp -= B*T
        # 倒せていなければ追加ダメージを与える
        if hp > 0:
            cnt += (hp-1) // (A-B) +1
    # 追加ダメージに使用した合計爆破数がT回以内かどうか判定
    if cnt <= T:
        return True
    else:
        return False

# 2分探索で最初にTrueになる場所を見つける
hi = 10 ** 9
low = 0
while low+1 < hi:
    mid = (hi+low) // 2
    if enough(mid):
        hi = mid
    else:
        low = mid
print(hi)

# hi = 10 ** 9 + 1
# low = 0
# mid = 10 ** 9 // 2
# while low+1 < hi:
#     if enough(mid):
#         hi = mid
#     else:
#         low = mid
#     mid = (hi+low+1) // 2
# print(mid)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
H=[int(input()) for i in range(N)]
C = A-B
def tao(k):
    num=0
    for h in H:
        t = h -B*k
        if t >0:
            num += t//C
            if t %C !=0:
                num +=1
    if num <= k:
        return True
    else:
        return False

mi =0
ma=10**9+1
while ma-mi>1:
    mid = (ma +mi)//2
    if tao(mid):
        ma=mid
    else:
        mi=mid
print(ma)

Submission status: Accepted

Solution code:
n,a,b = (int(i) for i in input().split())
h = [int(input()) for i in range(n)]
def dmg(x):
	num = 0
	for i in h:
		if i>b*x: num+=(i-b*x-1)//(a-b)+1
	return num<=x
hi,lo = 10**9+1,0
while hi-lo!=1:
	mid = (hi+lo)//2
	if dmg(mid): hi=mid
	else: lo=mid
print(hi)

Submission status: Accepted

Solution code:
import math
n, a, b=[int(i) for i in input().split()]
ab=a-b
t=[int(input()) for i in range(n)]
mx = sum([i//a +1 for i in t])
mi = 1

while mx - mi > 1:
  i = (mx + mi) // 2
    
  if sum([max(math.ceil((j- i * b) /ab),0) for j in t ]) <= i:
    mx = i
  else:
    mi = i
  
print(mx)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
H=[]
s=0
cnt_max=0

for i in range(N):
  h=int(input())
  s+=h
  cnt_max+=(h//A+1)
  H.append(h)

cnt_min=sum(H)//(B*N+(A-B)*N)
H.sort(reverse=True)
  
def check(n):
  res=n
  dmg=A-B
  dmg2=n*B
  for i in range(N):
    if H[i]>dmg2:
      if (H[i]-dmg2)%dmg==0:
        res-=((H[i]-dmg2)//dmg)
      else:
        res-=((H[i]-dmg2)//dmg+1)  
    if res<0:
      return False
  return True

while True:
  if cnt_min+1==cnt_max:
    if check(cnt_min):
      print(cnt_min)
      break
    else:
      print(cnt_max)
      break
  ans=(cnt_min+cnt_max)//2
  if check(ans):
    cnt_max=ans
  else:
    cnt_min=ans

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
src = [int(input()) for i in range(N)]
src.sort(reverse=True)

def isok(n):
    if all(h <= n*B for h in src):
        return True
    m = 0
    for h in src:
        h -= n*B
        m += (h-1)//(A-B) + 1
        if m > n:
            return False
    return True

ok = 10**9
ng = 0
while ok-ng > 1:
    m = (ok+ng) // 2
    if isok(m):
        ok = m
    else:
        ng = m
print(ok)

Submission status: Accepted

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

i = 10 ** 9
left, mid, right = 0, i // 2, i + 1

def attack(x):
    global n, a, b
    d = a - b
    remain = x
    for j in monsters:
        temp = j - b * x
        if temp > 0:
            remain -= (temp + d - 1) // d
    return remain >= 0

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

print(mid)

Submission status: Accepted

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

from math import ceil

def can_korosu(t):
    count = 0
    for h in H:
        count += ceil(max(0, h - t*B)/(A-B))
        if count > t:
            return False
    return True

lo = 0
hi = 10**9

p = (lo, hi)
for _ in range(50):
    mid = (hi + lo) // 2
    if can_korosu(mid):
        hi = mid
    else:
        lo = mid
    if p == (lo, hi):
        break
    p = (lo, hi)
print(hi)

Submission status: Accepted

Solution code:
import math

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

add_damage = A-B
left = 1
right = 10**9
ans = float('inf')

for i in range(int(math.log(10**9, 2)+1)):
    T = (left+right) // 2
    h = H.copy()
    h = list(map(lambda x: math.ceil(max(0, x-T*B) / add_damage), h))
    need = sum(h)
    
    if need <= T:
        right = T
        ans = min(ans, T)
    else:
        left = T

print(ans)

Submission status: Accepted

Solution code:
import math

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

add_damage = A-B
left = 1
right = 10**9
ans = float('inf')

for i in range(int(math.log(10**9, 2)+1)):
    T = (left+right) // 2
    h = H.copy()
    h = list(map(lambda x: max(0, x-T*B), h))
    h = list(map(lambda x: math.ceil(x / add_damage), h))
    need = sum(h)
    
    if need <= T:
        right = T
        ans = min(ans, T)
    else:
        left = T

print(int(ans))

Submission status: Accepted

Solution code:
def d_Widespread(N, A, B, H):
    from math import ceil
    low = 0
    high = max(H) // B + 1  # 多くともこの回数だけ魔法を使えば全滅できる

    def enough(t):
        time = 0
        for h in H:
            if h > B * t:
                # Bt以下の体力の魔物は魔法の巻き添えで倒す(狙う必要がない)
                time += ceil((h - B * t) / (A - B))
        if time <= t:
            return True
        else:
            return False

    while high - low > 1:
        mid = (low + high) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
    return high

N,A,B = [int(i) for i in input().split()]
H = [int(input()) for _ in range(N)]
print(d_Widespread(N, A, B, H))

Submission status: Accepted

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

INF = int(1e9)
l, m, r = 0, INF//2, INF + 1

def calc(n):
    global N, A, B
    d = A - B
    remain = n
    for h in hs:
        tmp = h - B * n
        if tmp > 0:
            remain -= (tmp + d - 1) // d
    return remain >= 0

while r - l > 1:
    if calc(m):
        r = m
    else:
        l = m
    m = (r + l + 1) // 2

print(m)

Submission status: Accepted

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

high=max(h)/B+1
low=1

def enough(T):
	cnt=0
	for i in h:
		i-=T*B
		if i>0:
			if i%(A-B)==0:
				cnt+=i/(A-B)
			else:
				cnt+=i/(A-B)+1
	if cnt<=T:
		return True
	else:
		return False

ans=0
while low<=high:
	c= (low + high) / 2
	if enough(c):
		high=c-1
		ans=c
	else:
		low=c+1


print ans

Submission status: Accepted

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

high=max(h)
low=1

def enough(T):
	cnt=0
	for i in h:
		i-=T*B
		if i>0:
			if i%(A-B)==0:
				cnt+=i/(A-B)
			else:
				cnt+=i/(A-B)+1
	if cnt<=T:
		return True
	else:
		return False

ans=0
while low<=high:
	c= (low + high) / 2
	if enough(c):
		high=c-1
		ans=c
	else:
		low=c+1


print ans

Submission status: Accepted

Solution code:
import math
import sys
sys.setrecursionlimit(100000000)

N, A, B = [int(n) for n in input().split()]
h = []
for i in range(N):
  h.append(int(input()))

def bsearch(begin, end):
  if begin == end:
    return begin
  else:
    if is_ok( (begin+end)//2):
      return bsearch(begin, (begin+end)//2)
    else:
      return bsearch( (begin+end)//2 + 1, end)

def is_ok(n):
  h_tmp = h.copy()
  cnt = 0
  cnt = sum([math.ceil((hp-B*n)/(A-B)) for hp in h_tmp if hp-B*n >= 0])
  return cnt <= n

print(bsearch(0, 1000000000))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://abc063.contest.atcoder.jp/tasks/arc075_b
TLE
"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline


def Cond(monsters, A, B, mid):
    t = [x - (B * mid) for x in monsters]
    t.sort(reverse=True)
    additional_damage = (A - B)

    total_count = 0
    for m in t:
        if m < 1:
            break
        total_count += ceil(m / additional_damage)

    if total_count <= mid:
        return True
    else:
        return False


def main(args):
    # N = 2
    # A = 10
    # B = 4
    # monsters = [20, 20]
    N, A, B = map(int, input().split())
    monsters = [int(input()) for _ in range(N)]

    total_count = 0
    if N == 1:
        total_count = ceil(monsters[0] / A)
    else:
        monsters.sort(reverse=True)
        lb = ceil(monsters[0] / A)
        ub = ceil(monsters[0] / B)
        # lb = 0
        # ub = 1e10

        for _ in range(30):
            mid = (lb + ub) // 2
            if Cond(monsters, A, B, mid):
                ub = mid
            else:
                lb = mid
        total_count = int(ub)

    print(total_count)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
import math

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


def judge(K):
    sums = 0
    for i in h:
        t = i-K*B
        if t > 0:
            sums += math.ceil(t*1.0/(A-B))
            if sums > K:
                return False;
    return True


high = int(1e9)
low = 0

while low < high:
    mid = int((high + low) / 2)
    if judge(mid):
        high = mid;
    else:
        low = mid+1;

print low

Submission status: Accepted

Solution code:
import math

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

def judge(K):
    sums = 0
    for i in h:
        t = i-K*B
        if t > 0:
            sums += math.ceil(t*1.0/(A-B))
            if sums > K:
                return False;
    return True

high = int(1e9)
low = 0

while high > low:
    mid = int((high + low) / 2)
    if judge(mid):
        high = mid;
    else:
        low = mid+1;

print low

Submission status: Accepted

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

import math

def enough(T):
    num = 0
    for hi in h:
        if hi - B * T <= 0:
            return True

        num += math.ceil((hi - B * T) / (A - B))
        if num > T:
            return False

    return True

h.sort(reverse=True)

iFrom = 1
iTo = math.ceil(h[0] / B)
while iFrom != iTo:
    iMid = iFrom + (iTo - iFrom) // 2

    if enough(iMid) == True:
        iTo = iMid
    else:
        iFrom = iMid + 1

print(iFrom)

Submission status: Accepted

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

C=A-B
sum,d=0,0
high = math.ceil(max(H)/B)
low = 0
while high > low:
    sum = 0
    mid = (high + low) //2
    for i in range(N):
        if H[i]-B*mid > 0:
            sum += math.ceil((H[i]-B*mid)/C)
    if sum <= mid:
        high = mid
    else:
        low = mid + 1

print(low)

Submission status: Accepted

Solution code:
from math import ceil

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

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

high = ceil(max(h) / B)
low = 0

while high - low > 0:
    mid = (high + low) // 2
    if enough(mid):
        high = mid
    else:
        low = mid + 1

print(low)

Submission status: Accepted

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 > 0):
    mid = (high + low) // 2
    if(enough(mid)):
        high = mid
    else:
        low = mid + 1
print(low)

Submission status: Accepted

Solution code:
from math import ceil

N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))
    
left = 0
right = max(h)//B + 1

while right - left > 1:
    mid = (right + left) // 2
    c = sum([ceil((hi-mid*B)/(A-B)) for hi in h if hi > mid * B])
    if c > mid:
        left = mid
    else:
        right = mid
        
print(right)

Submission status: Accepted

Solution code:
from math import ceil

N, A, B = map(int, input().split())
H = []
for _ in range(N):
    H.append(int(input()))
    
left = 0
right = max(H)//B + 1

while right - left > 1:
    mid = (right + left) // 2
    c = sum([ceil((h-B*mid)/(A-B)) for h in H if h > B*mid])
    
    if c > mid:
        left = mid
    else:
        right = mid
print(right)

Submission status: Accepted

Solution code:
from collections import defaultdict
from math import ceil


def can_kill(total, A, B, h_list):
    add = A - B
    num = 0
    for h in h_list:
        h -= B * total
        num += ceil(h / add)
        if num > total:
            return False
    return True


def main():
    N, A, B = map(int, input().split())
    h_list = list(sorted([int(input()) for _ in range(N)], reverse=True))

    left, right = -1, 10 ** 10
    ans = 0
    while right - left > 1:
        m = (left + right) // 2
        if can_kill(m, A, B, h_list):
            ans = m
            right = m
        else:
            left = m
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

import math as m

imin = 1
imax = sum([hh // a + 1 for hh in h])

while ( imax > imin+1 ):
    num = imin + (imax-imin)//2
    acnt = sum([m.ceil((hi- b*num)/(a-b)) for hi in h  if (hi- b*num)>0])
    if ( acnt<=num ):
        imax = num
    else:
        imin = num
print(imax)

Submission status: Accepted

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

import math as m

imin = 1
imax = sum([hh // a + 1 for hh in h])

while ( imax > imin+1 ):
    num = imin + (imax-imin)//2
    acnt = sum([m.ceil((hi- b*num)/(a-b)) for hi in h  if (hi- b*num)>0])
    if ( acnt<=num ):
        imax = num
    else:
        imin = num
print(imax)

Submission status: Accepted

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

import math

sup = sum([hh // a + 1 for hh in h])
inf = 1
 
while sup - inf > 1:
    x = (sup + inf) // 2
    c = sum([math.ceil((hh - x * b)/(a-b)) for hh in h if hh > x * b])
    if c <= x:
        sup = x
    else:
        inf = x
 
print(sup)

Submission status: Accepted

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 :
    tmp = h-B*now
    if now >= sum(np.ceil(tmp[tmp>0]/(A-B))) :
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(mx))

Submission status: Accepted

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 :
    if (mx-mn) == 1 :
        tmp_mx = h-B*mx
        tmp_mn = h-B*mn
        T_mx = sum(np.ceil(tmp_mx[tmp_mx>0]/(A-B)))
        T_mn = sum(np.ceil(tmp_mn[tmp_mn>0]/(A-B)))

        if T_mn == mn :
            ans = mn
        else :
            ans = mx

        break

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

    now = (mx+mn)//2

print(int(ans))

Submission status: Accepted

Solution code:
import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        if (h -b*T) >= 0:
            cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return True
    else:
        return False

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

H = sorted([int(input()) for i in range(tmp[0])])[::-1]
minT = 0
maxT = math.ceil(H[0] / b)
T = int((maxT + minT) / 2)

while True:
    T = math.ceil((maxT + minT) / 2)
    if calc(H, T, a, b):
        maxT = T
    else:
        minT = T
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Accepted

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

N, A, B = map(int, input().split(' '))
hn = [int(input()) for i in range(N)]

maxT = max(hn) // B + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) if (h - B*T) >= 0 else 0 for h in hn])
    return True if count <= T else False

while True:
    med = (maxT + minT) // 2
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Accepted

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

N, A, B = map(int, input().split(' '))
hn = sorted([int(input()) for i in range(N)])

maxT = hn[-1] // B + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) if (h - B*T) >= 0 else 0 for h in hn])
    return True if count <= T else False

while True:
    med = (maxT + minT) // 2
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Accepted

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

N, A, B = map(int, input().split(' '))
hn = sorted([int(input()) for i in range(N)])

maxT = int(hn[-1] / B) + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) if (h - B*T) >= 0 else 0 for h in hn])
    return True if count <= T else False

while True:
    med = int((maxT + minT) / 2)
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import math
import sys

line = input().split(' ')
N = int(line[0])
A = int(line[1])
B = int(line[2])
hn = sorted([int(input()) for i in range(N)])

maxT = int(hn[-1] / B) + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) if math.ceil((h - B*T) / (A-B)) >= 0 else 0 for h in hn])
    return True if count <= T else False

while True:
    med = int((maxT + minT) / 2)
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)