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:
import math

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


def enough(T):
    h2 = list(map(lambda x: x - B * T, h))
    return sum(map(lambda x: max(0, math.ceil(x / (A - B))), h2)) <= T


def solver(inf, sup):
    mid = (inf + sup) // 2
    if inf == sup:
        return mid
    elif enough(mid):
        return solver(inf, mid)
    else:
        return solver(mid + 1, sup)


t = 10 ** 9

print(solver(0, t))

Submission status: Accepted

Solution code:
from math import ceil
N, A, B = map(int, raw_input().split(' '))
h = [int(raw_input()) for _ in range(N)]

def enough(T):
    bt = B * T
    ab = A - B
    atk = sum([ceil(float(v - bt) / ab) for v in h if v > bt])
    if atk <= T:
        return True
    return False

l = 0
r = max(h) / B + 1
while r - l > 1:
    T = (l + r) / 2
    if enough(T):
        r = T
    else:
        l = T
if r == 2:
    if enough(1):
        r = 1
print r

Submission status: Accepted

Solution code:

import math

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


def enough(T):
    atack = B * T
    diff = A - B
    count = 0
    for i in h:
        tmp = math.ceil((i - atack) / diff)
        if tmp > 0:
            count += tmp

    return count<=T


def tree():
    low = 0
    high = 10 ** 9
    while high - low > 1:
        mid = (low + high) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
    return high


print(tree())

Submission status: Accepted

Solution code:
#coding: utf-8
import math

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


def enough(T):
    attack = B * T
    diff = A-B
    count = 0
    for i in monster:
        tmp = math.ceil((i - attack)/diff)
        if tmp > 0:
            count += tmp

    if count <= T:
        return True
    else:
        return False

def bs():
    left = 0
    right = 1000000000

    while left < right:
        mid = (left + right) // 2
        if enough(mid):
            right = mid
        else:
            left = mid + 1
    return left

print(bs())

Submission status: Accepted

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


def enough(T):
    total = 0
    for x in h:
        if x >= b * T:
            q, r = divmod(x - b * T, a - b)
            ceiling = q + int(r != 0)
            total += ceiling
    return total <= T


l = 0
r = 10 ** 9
while r - l > 1:
    m = (l + r) // 2
    if enough(m):
        r = m
    else:
        l = m
print(r)

Submission status: Accepted

Solution code:
import math
import sys

# sys.stdin = open("d1.in")

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

sup = 10 ** 9
inf = 0

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

print(sup)

Submission status: Accepted

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

Solution code:
def check(N,A,B,h,K):
    sum = 0
    for i in range(N):
        x = -((-h[i]+B*K)//(A-B))
        sum += x if x>0 else 0
    return sum<=K

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

ok = 1000000000
ng = 0
while abs(ok -ng)>1:
    mid = (ok+ng)//2
    if check(N,A,B,h,mid):
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Accepted

Solution code:
import math

def bs(n, a, b, hp, min=0, max=10**9):
    left = min
    right = max
    def count(num):
        base = b * num
        attackcount = 0
        diff = a-b
        for i in range(n):
            tmp = math.ceil((hp[i] - base) / diff)
            if tmp <= 0:
                pass
            else:
                attackcount += tmp
        if attackcount <= num:
            return True
        else:
            return False
    while left != right:
        mid = (left + right) // 2
        if count(mid):
            right = mid
        else:
            left = mid + 1
    return left

if __name__ == '__main__':
    n, a, b = map(int, input().split())
    hp = [int(input()) for i in range(n)]
    print(bs(n, a, b, hp))

Submission status: Accepted

Solution code:
import math

def enough(n):
    whole_damage = B * n
    if (SUM > whole_damage*N + (A-B)*n):
        return False
    if (MAX <= whole_damage):
        return True
    arr = filter(lambda hp: hp > whole_damage, HPS)
    atk_times = 0
    for hp in arr:
        atk_times += int(math.ceil((hp - whole_damage)*1.0 / (A-B)))
        if atk_times > n:
            return False
    else:
        return True

N,A,B = map(int, raw_input().split())
HPS = [input() for i in range(N)]
MAX = max(HPS)
SUM = sum(HPS)

left = 1
right = MAX/B + 1
while left < right:
    mid = (left + right)/2
    if enough(mid):
        right = mid
    else:
        left = mid + 1
print right

Submission status: Accepted

Solution code:
import math


def C(_mid):
    tmp = [x - B * _mid for x in h]
    explode_count = 0
    for i in range(0, len(tmp)):
        if tmp[i] <= 0:
            pass
        else:
            explode_count += math.ceil(tmp[i] / (A - B))

    if _mid < explode_count:
        return True
    else:
        return False


if __name__ == '__main__':
    N, A, B = list(map(int, input().split()))

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

    lb = 0
    ub = 1000000000
    while ub - lb > 1:
        mid = int((lb + ub) / 2)
        if C(mid):
            lb = mid
        else:
            ub = mid

    print(ub)

Submission status: Accepted

Solution code:
import math
 
def check(x):
    k = 0
    global h, a, b
    for i in h:
        if x * b < i:
            k += math.ceil((i - x * b) / (a - b))
    return k <= x
 
 
n, a, b = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
l = -1
r = max(h) // b + 1
while r - l > 1:
    m = (l + r) // 2
    if check(m):
        r = m
    else:
        l = m
print(r)

Submission status: Accepted

Solution code:
#coding=UTF-8
myon_chache={}
def turn_check(zikan,direct,around):
    nokori_naka=zikan
    for idx in range(0,N,1):
        rem_hp=kirei_HP[idx]-around*zikan
        if rem_hp > 0:
            if rem_hp in myon_chache:
                myon=myon_chache[rem_hp]
            else:
                myon= rem_hp//(direct-around) + (0 if rem_hp%(direct-around)==0 else 1)
                myon_chache[rem_hp]=myon
        
            nokori_naka=nokori_naka-myon
            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)
dmg_mean= B
kagen=kirei_HP[0]// dmg_mean + 1
tansaku=kagen//2
ite=0
dame_jogen=0
while True:
    ite=ite+1
    if turn_check(tansaku,A,B):
        kagen=tansaku
        tansaku=(kagen+dame_jogen)//2
    else:
        if tansaku + 1 == kagen: #丁度境目を見付けたら
            break
        else:
            dame_jogen=tansaku
            tansaku=(tansaku+kagen)//2

#print(ite)
print(kagen)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

    left = 0
    right = 10**9

    def is_ok(t):
        return sum(map(lambda x: max(0, x - b*t + d-1) // d, l)) <= t

    while abs(left - right) > 1:
        now = (left + right) // 2
        if is_ok(now):
            right = now
        else:
            left = now

    print((right, left)[is_ok(left)])

d()

Submission status: Accepted

Solution code:
import numpy as np
n, a, b = map(int, raw_input().split())
h = []
for i in xrange(n):
    h.append(int(raw_input()))
h = np.array(h)
count = 0
adiff = float(a - b)
top = max(h) / b + 1
bottom = 0
mid = top / 2
while(1):
    if top - bottom < 2:
        break
    hmem = h - b * mid
    if np.sum(np.ceil(hmem[hmem > 0] / adiff)) <= mid:
        top = mid
    else:
        bottom = mid
    mid = (top + bottom) / 2
print top

Submission status: Accepted

Solution code:
import math

def check(x):
    k = 0
    global h, a, b
    for i in h:
        if x * b < i:
            k += math.ceil((i - x * b) / (a - b))
    return k <= x


n, a, b = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
l = -1
r = max(h) // b + 1
while r - l > 1:
    m = (l + r) // 2
    if check(m):
        r = m
    else:
        l = m
print(r)

Submission status: Accepted

Solution code:
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

def solve(hp, count):
	q = hp - b * count
	p = (q - 1) / (a - b) + 1
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 0
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(ll, m):
		r = m
	else:
		l = m

print r

Submission status: Accepted

Solution code:

import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

def solve(hp, count):
	q = hp - b * count
	t = q > 0

	if a > b:
		p = (q - 1) / (a - b) + 1
	else:
		p = q
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(ll, m):
		r = m
	else:
		l = m

if r == 2:
	if solve(ll, 1):
		r = 1

print r

Submission status: Accepted

Solution code:
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

# print count
def solve(count):
	q = ll - b * count
	t = q > 0

	if a > b:
		p = (q - 1) / (a - b) + 1
	else:
		p = q
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(m):
		r = m
	else:
		l = m

if r == 2:
	if solve(1):
		r = 1

print r

Submission status: Accepted

Solution code:
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

# print count
def solve(count, hpList):
	q = hpList - b * count
	t = q > 0

	if a > b:
		p = (q - 1) / (a - b) + 1
	else:
		p = q
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(m, ll):
		r = m
	else:
		l = m

if r == 2:
	if solve(1, ll):
		r = 1

print r

Submission status: Accepted

Solution code:
n, A, B = map(int, input().split())
l = [int(input()) for x in range(n)]

left = 0
right = 10**9


def is_ok(t):
    AB = A - B
    return sum(map(lambda x: max(0, x - B*t + (AB - 1)) // (AB), l)) <= t


while abs(left - right) > 1:
    now = (left + right) // 2
    if is_ok(now):
        right = now
    else:
        left = now

print([right, left][is_ok(left)])

Submission status: Accepted

Solution code:
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N, A, B = ILI()
    h = [II() for __ in range(N)]
    return (N, A, B, h)


def bool_exc(h, dif_ab, B, count):
    dif_count = 0
    for mon in h:
        dif_mon = mon - B * count
        if dif_mon <= 0:
            continue
        else:
            dif_count += math.ceil(dif_mon / dif_ab)
            if dif_count > count:
                break

    dif = count - dif_count
    return dif


def solve(N, A, B, h):
    right = max(h) // B + 1
    left = min(h) // A + 1
    dif_ab = A - B
    while left != right:
        mid = (left + right) // 2
        dif = bool_exc(h, dif_ab, B, mid)
        if dif >= 0:
            right = mid
        else:
            left = mid + 1

    ans = left
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Accepted

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


sp_damage = A-B
"""
heap = []
for hval in h:
    heapq.heappush(heap,-hval)
count = 0
while True:
    if heap[0]  >= -count*B:
        break
    count+=1
    hp = heapq.heappop(heap)
    hp += sp_damage
    heapq.heappush(heap,hp)
print(count)

"""
def nibun(func ,min_ ,max_ ):
    left = min_
    right= max_
    while not(left==right):
        mid = (left+right) //2
        tmp = func(mid)
        if tmp:
            right = mid
        else:
            left = mid+1
    return left

def check(num):
    i = num
    for hval in h:
        rest = hval-B*num
        if rest <= 0 :
            continue
        i -= math.ceil(rest/sp_damage)
        #print(rest,i)
        # sp * m + B*hval
    return i>=0

print(nibun(check,0,1000000000))

Submission status: Accepted

Solution code:
import math

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

sup = sum([h // A + 1 for h in H])
inf = 1

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

print(sup)

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    long N, A, B;
    cin >> N >> A >> B;
    vector<long> h;
    for (int i=0; i<N; i++){
        long input;
        cin >> input;
        h.push_back(input);
    }

    
    long ans = 0;
    vector<long> temp;
    while (h.size() != 0){
        bool first = true;
        make_heap(h.begin(),h.end());
        for (auto x : h){
            if (first) {x -= A; first = false;}
            else{ x -= B;}
            if (x > 0) temp.push_back(x);
        }
        h.clear();
        for (auto x : temp) h.push_back(x);
        temp.clear();
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, A, B = MAP()
h = [INT() for _ in range(N)]
h.sort(reverse = True)

def is_ok(x):
    h_copy = h[:]
    for i in range(N):
        h_copy[i] -= B*x
    cnt = 0
    for i in range(N):
        cnt += max(0, ceil(h_copy[i]/(A-B)))
    return cnt <= x

while l+1 != r:
	p = -(-l-r)//2
	if is_OK(p):
		r = p
	elif is_OK(p)==0:
		l = p


if is_OK(p):
	print(p)
else:
	print(p+1)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, A, B = MAP()
h = [INT() for _ in range(N)]
h.sort(reverse = True)

def is_OK(T):
	H = h.copy()
	H = [x-B*T for x in h]
	tmp = 0
	for x in H:
		tmp += max(0, -(-x//(A-B)))
		if T < tmp:
			return 0
			break
	else:
		return 1
l = 0
r = -(-max(h)//B)

while l+1 != r:
	p = -(-l-r)//2
	if is_OK(p):
		r = p
	elif is_OK(p)==0:
		l = p


if is_OK(p):
	print(p)
else:
	print(p+1)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    # https://qiita.com/drken/items/97e37dd6143e33a64c8c#3-%E3%82%81%E3%81%90%E3%82%8B%E5%BC%8F%E4%BA%8C%E5%88%86%E6%8E%A2%E7%B4%A2%E3%81%AE%E3%81%95%E3%82%89%E3%81%AA%E3%82%8B%E5%88%A9%E7%82%B9

    n,a,b=map(int,input().split())
    h=[int(input()) for _ in range(n)]
    def is_ok(t):
        cnt=0
        for i in range(n):
            val=math.ceil((h[i]-b*t) / (a-b))
            cnt+=val
        if cnt<=t:
            return True
        else: return False

    def bin_search_meguru():
        """
        初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
        まずis_okを定義すべし
        ng, okは,とり得る最小の値-1,とり得る最大の値+1
        """
    
        # 適当にいじる
        ng = 0  # ind=0が条件を満たすこともあるため
        ok = 10**9+1  # ind=len(a)-1が条件を満たさないこともあるため
    
        # いじらない
        # okとngのどちらが大きいかわからないことを考慮
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok
    print(bin_search_meguru())
    

    
resolve()

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
H = sorted([int(input()) for _ in range(N)])
d = A-B
high = H[-1]//B
low = 1
while high-low>1:
    mid = (high+low)//2
    cnt = 0
    for i in range(N):
        cnt += (H[i]-B*mid)//d
    if cnt<=K:
        high = mid
    else:
        low = mid
print(high)

Submission status: Runtime Error

Solution code:
from numpy import ceil,array,sum

def is_ok(m):

    tmp = h - m*B

    if not any(tmp):
        return True

    rem = [ceil(i/(A-B)) for i in tmp[tmp>0]]
    
    if rem > m:
        return False

    return True

N,A,B = map(int,input().split())
h = array(list(int(input()) for _ in range(N)))
s = sum(h)
##二分散策

r = 10**9
l = 0

while abs(l-r) > 1:

    m = (r+l)//2

    if is_ok(m):
        r = m
    else:
        l = m

print(r)

Submission status: Runtime Error

Solution code:
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
n1=(b1-a1)*t1
n2=(b2-a2)*t2
if n1*n2>0 or abs(n1)>abs(n2):
  print(0)
elif abs(n1)==abs(n2):
  print('infinity')
else:
  c=abs(n1)//abs(n1+n2)
  while (c+1)*abs(n1+n2)<=abs(n1):
    c+=1
  ans=2*c
  if abs(n1)%(abs(n1+n2))!=0:
    ans+=1
  print(ans)

Submission status: Runtime Error

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

def explode(x):
    global n
    c=0
    for i in range(n):
        if h[i]-x*b>0:
            c+=math.ceil((h[i]-x*b)/(a-b))
    return c<=x

#二分探索用のコード

#(1)l,rは両端点でl<=r
l,r=1,10**9
#(2)l=rもしくはl=r-1のときにbreak
while l+1<r:
    #(3)その閉区間の中点(の小数部分を切り捨てたもの)
    #オーバーフローを考慮すると以下の書き方になる
    k=l+.round((r-l)/2)
    #ここでは境目以上のxで真になるので、
    #x=kで真の場合は大きい方の端点をkにし、x=kで偽の場合は小さい方の端点をkにする
    if explode(k):
        r=k
    else:
        l=k

print(l if explode(l) else r)

Submission status: Runtime Error

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

def explode(x):
    global n
    c=0
    for i in range(n):
        if h[i]-x*b>0:
            c+=math.ceil((h[i]-x*b)/(a-b))
    return c<=x

#二分探索用のコード

#(1)l,rは両端点でl<=r
l,r=1,10**9
#(2)l=rもしくはl=r-1のときにbreak
while l+1<r:
    #(3)その閉区間の中点(の小数部分を切り捨てたもの)
    #オーバーフローを考慮すると以下の書き方になる
    k=l+math.round((r-l)/2)
    #ここでは境目以上のxで真になるので、
    #x=kで真の場合は大きい方の端点をkにし、x=kで偽の場合は小さい方の端点をkにする
    if explode(k):
        r=k
    else:
        l=k

print(l if explode(l) else r)

Submission status: Runtime Error

Solution code:
l,r=1,10**9
#(2)l=rもしくはl=r-1のときにbreak
while l+1<r:
    #(3)その閉区間の中点(の小数部分を切り捨てたもの)
    #オーバーフローを考慮すると以下の書き方になる
    k=l+(r-l)//2
    #ここでは境目以上のxで真になるので、
    #x=kで真の場合は大きい方の端点をkにし、x=kで偽の場合は小さい方の端点をkにする
    if explode(k):
        r=k
    else:
        l=k

print(l if explode(l) else r)

Submission status: Runtime Error

Solution code:
import numpy as np
N, A, B = map(int,input().split())
h = []
for _ in range(N):
    h.append(int(input()))
 
def solve(n):
    H = np.array(h)
    H -= B * n
    cnt = 0
    for i in H:
        cnt += max((i - 1) // (A - B) + 1, 0)
    return cnt <= n
 
left = 0
right = 10 ** 9

while left + 1 < right:
    mid = (left + right) // 2
    if solve(mid):
        right = mid
    else:
        left = mid
 
print(right)

Submission status: Runtime Error

Solution code:
import numpy as np
N, A, B = map(int,input().split())
h = []
for _ in range(N):
    h.append(int(input()))
 
def solve(n):
    H = np.array(h)
    H -= B * n
    cnt = 0
    for i in H:
        cnt += (i - 1) // (A - B) + 1
    return cnt <= n
 
left = 0
right = 10 ** 9
 
while left + 1 < right:
    mid = (left + right) // 2
    if solve(mid):
        right = mid
    else:
        left = mid
 
print(right)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
H=[]
for i in range(N):
  H.append(int(input()))
ans=0
n=N
while n>0:
  mi=0
  for i in range(n):
    if H[i]>=0: H[i]-=B=i
  H[mi]-=(A-B)
    if H[mi]<H[i]: mi
  while n>0 and H[n-1]<=0: n-=1
  ans+=1
print(ans)

Submission status: Runtime Error

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

# x回で全モンスター倒せるかどうかをにぶちゃん(にぱー)

import math

def check(x):
    count = 0
    for i in range(N):
        count += math.ceil(max(h[i] - B * x, 0) / (A - B))
           
    if count <= x:
        return True
    else:
        return False
    
def solve():
    
    while abs(right-left) > 1:
    
        left = -1
        right = 10**9+1
    
        center = (right+left)//2
    
        if check(center) == True:
            right = center
        elif check(center) == False:
            left = center
        
    return right
    
print(solve())

Submission status: Runtime Error

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

d = [0]*n
for i in range(n):
    e = c[i]//b
    if c[i] % b != 0:
        e +=1
    d[i] = e

f = sum(c)
ans = 0
num = 0
g = 0
while f > 0:
    g += e.count(num)
    f = f - (a-b) - b *(n-g)
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N, A, B , *h = map(int, open('0').read().split())
C = A-B
l = -1
r = 10**12
while l+1<r:
  s = (l+r)//2
  M = [c-s*B for c in h]
  cnt = sum((c+C-1)//C if c>0 else 0 for c in M)
  if cnt>s:
    l = s
  else:
    r = s
print(r)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
h =[0]*n
for i in range(n):
    h[i]=int(input())
def hantei(now):
    ab=a-b
    nokori = sum(kiriage( max(0,hh-now*b) ,ab)//ab  for hh in h)
    return nokori<=now
def kiriage(x,c):
    if x%c==0:
        return x
    else:
        return (x//c+1) *c

ma = 10**9//b +1
mi = 1
while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)
#     print(which,mi,now,ma)
    if which:
        ma=now
        ans=now
    else:
        mi=now+1
print(ans)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
h =[0]*n
for i in range(n):
    h[i]=int(input())
def hantei(now):
    ab=a-b
    nokori = sum(kiriage( max(0,hh-now*b) ,ab)//(ab)  for hh in h)
    return nokori<=now
def kiriage(x,c):
    if x%c==0:
        return x
    else:
        return (x//c+1) *c

ma = 10**9//b +1
mi = 1
while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)
#     print(which,mi,now,ma)
    if which:
        ma=now
        ans=now
    else:
        mi=now+1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N, A, B = map(int, input().split())
H = np.array([int(input()) for _ in range(N)], dtype=np.int64)


def C(X):
    """
    x回爆発して、全部消滅させれるとTrue
    """
    HP = np.copy(H)
    HP -= B * X
    cnt = ((HP + A - B - 1) // (A - B)).sum()
    return cnt <= X


l = -1
r = 10 ** 18
while r - l > 1:
    m = (r + l) // 2
    if C(m):
        r = m
    else:
        l = m

ans = r
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
input = sys.stdin.readline

N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = np.array(H, dtype=np.int64)


def C(X):
    """
    x回爆発して、全部消滅させれるとTrue
    """
    HP = np.copy(H)
    HP -= B * X
    HP[HP <= 0] = 0
    cnt = ((HP + A - B - 1) // (A - B)).sum()
    return cnt <= X


l = -1
r = 10 ** 18
while r - l > 1:
    m = (r + l) // 2
    if C(m):
        r = m
    else:
        l = m

ans = r
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
input = sys.stdin.readline

N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = np.array(H, dtype=np.int64)


def C(X):
    """
    x回爆発して、全部消滅させれるとTrue
    """
    HP = np.copy(H)
    HP -= B * X
    HP[HP <= 0] = 0
    cnt = ((HP + A - B - 1) // (A - B)).sum()
    return cnt <= X


l = 0
r = 10 ** 18
while r - l > 1:
    m = (r + l) // 2
    if C(m):
        r = m
    else:
        l = m

ans = r
print(ans)

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(x):
  cnt=0
  for i in range(n):
    if h[i]-x*b<=0:
      continue:
    cnt+=ceil((h[i]-x*b)/(a-b))
  if cnt<=x:
    return True
  else:
    return False
l=0
r=10**9
while r-l>0:
  mid=(r+l)//2
  if enough(mid):
    r=mid
  else:
    l=mid+1
print(r)

Submission status: Runtime Error

Solution code:
from math import ceil 
n,a,b=map(int,input().split())
l=[int(input()) for i in range(n)]
def check(x):
    c=0 
    l1=[i-b*x for i in l]
  #  print(l1)
    bc=x  
    r=x 
    for i in l1: 
        if i<=0:
            continue 
        else:
            c+=ceil(i/a)
            z=i//a 
            z1=a-i%a
            r-=(z1//b)
   # print(r)
    if r>=0:
        c+=ceil((r*b)/a)
    return c<=x
lo=1 
ans=-1 
hi=10**10
#print(check(2))

while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1
    else:
        lo=mi+1 
print(ans) 
from math import ceil 
n,a,b=map(int,input().split())
l=[int(input()) for i in range(n)]
def check(x):
    c=0 
    l1=[i-b*x for i in l]
  #  print(l1)
    bc=x  
    r=x 
    for i in l1: 
        if i<=0:
            continue 
        else:
            c+=ceil(i/a)
            z=i//a 
            z1=a-i%a
            r-=min((z1//b),x)
   # print(r)
    if r>=0:
        c+=ceil((r*b)/a)
    return c<=x
lo=1 
ans=-1 
hi=10**10
#print(check(2))

while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1
    else:
        lo=mi+1 
print(ans)