Problem:


Score : 400 points

Problem Statement

You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.

Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:

Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.

At least how many explosions do you need to cause in order to vanish all the monsters?

Constraints

All input values are integers.

1 ≤ N ≤ 10^5

1 ≤ B < A ≤ 10^9

1 ≤ h_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N A B
h_1
h_2
:
h_N

Output

Print the minimum number of explosions that needs to be caused in order to vanish all the monsters.

Sample Input 1

4 5 3
8
7
4
2

Sample Output 1

2

You can vanish all the monsters in two explosion, as follows:

First, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.

Second, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.

Sample Input 2

2 10 4
20
20

Sample Output 2

4

You need to cause two explosions centered at each monster, for a total of four.

Sample Input 3

5 2 1
900000000
900000000
1000000000
1000000000
1000000000

Sample Output 3

800000000



Sample input:
4 5 3
8
7
4
2


Sample output:
2

Submission status: Wrong Answer

Solution code:
def binary_search_int(ok, ng, test):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid):
            ok = mid
        else:
            ng = mid
    return ok

##############################################################

import sys
input = sys.stdin.readline

def test(x):
    cnt = 0
    for h in H:
        if h-x*B>0:
            cnt += ceil((h-x)/(A-B))
    return cnt >= x

from math import ceil
N, A, B = map(int, input().split())
H = []
for _ in range(N):
    H.append(int(input()))

res = binary_search_int(0,10**9+1,test)
print(res)

Submission status: Wrong Answer

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

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

h.sort(reverse=True)
tmp = 0
#print(ima_max)
#exit()
ans = 0

low = 1

high = 10**9

while low+1 < high:
    tmp = 0
    mid = (low + high) //2
    #print(mid)
    
    num = 0
    
    for i in range(n):
        num += max(0,(h[i]-mid*b+(a-b-1))//(a-b))
    #print(tmp)
    #print(num)
    
    if num <= mid:
        high = mid
    else:
        low = mid
        
print(high)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
H =[]
for i in range(N):
  H.append(int(input()))
H.sort(reverse=True)
  
def judge(k):
  mas=k
  S=B*k
  for i in range(N):
    l = H[i]-S
    if l>0:
      mas-=l//(A-B)+min(1,l%(A-B))
    if mas<0:
      return False
  return True
  
def binary(max):
  l=0
  r=max
  while l<=r:
    m=(l+r)//2
    j = judge(m)
    if j==True:
      r=m-1
    else:
      l=m+1   
  return m
print(binary(H[0]//B+1))

Submission status: Wrong Answer

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

def main():
    N,A,B = map(int,input().split())
    h = [int(input()) for _ in range(N)]
    left = 0
    right = sum(h)//A+1
    while right-left > 1:
        do = (left+right)//2
        count = 0
        for i in h:
            if i > do*B:
                count += math.ceil((i-do*B)/(A-B))
        if count > do:
            left = do
        else:
            right = do
    
    print(right)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
H=[int(input()) for i in range(N)]
l,r=1,10**9
v={}
import math
def f(n):
    s=0
    for h in H:
        s+=max(0,math.ceil((h-B*n)/(A-B)))
    return s
while 1:
    n=(r-l)//2+l
    if n in v:
        n+=1
    if n in v:
        break
    v[n]=1
    a=f(n)
    if a<n:
        r=n
    elif a>n:
        l=n
    else:
        break
print(a)

Submission status: Wrong Answer

Solution code:
a,b,c = map(int, input().split())
l = [int(input()) for _ in range(a)]
flag = True
l = sorted(l)
max_T = l[-1]//c + 1
def ok(k):
    s = k
    for i in l:
        hp = i - c * k
        if hp > 0:
            s -= -(-hp // (b - c))
        if s < 0:
            return False
    return True
def bbb(l,r):
    mid = (l + r) // 2
    if l == r:
        return l
    elif ok(mid):
        return bbb(l,mid)
    else:
        if mid == l:
            mid += 1
            
        return bbb(mid,r)
bbb(0,max_T)

Submission status: Wrong Answer

Solution code:
from math import *
s=raw_input().split(' ')
n=int(s[0])
a=int(s[1])
b=int(s[2])

h=[]
s=0
for i in range(n):
	k=raw_input() 
	h.append(int(k))
	s+=int(k)
l=1
if s%a==0:
	r=s//a
else:
	r=(s//a)+1
an=-1
while r>=l:
	m=(l+r)//2
	c=0
	for i in range(n):
		if (h[i]-b*m)%(a-b)==0:
			c=c+(h[i]-b*m)//(a-b)
		else:
			c=c+((h[i]-b*m)//(a-b)+1)
	if c<=m:
		an=m;
		r=m-1
	else:
		l=m+1
#print(r,l)
print(an)

Submission status: Wrong Answer

Solution code:
from math import *
s=raw_input().split(' ')
n=int(s[0])
a=int(s[1])
b=int(s[2])

h=[]
s=0
for i in range(n):
	k=raw_input() 
	h.append(int(k))
	s+=int(k)

l=1; r=n;
an=-1
while r>=l:
	m=(l+r)//2
	c=0
	for i in range(n):
		if (h[i]-b*m)%(a-b)==0:
			c=c+(h[i]-b*m)//(a-b)
		else:
			c=c+((h[i]-b*m)//(a-b)+1)
	if c<=m:
		an=m;
		r=m-1
	else:
		l=m+1
#print(r,l)
print(an)

Submission status: Wrong Answer

Solution code:
from math import *
s=raw_input().split(' ')
n=int(s[0])
a=int(s[1])
b=int(s[2])

h=[]
s=0
for i in range(n):
	k=raw_input() 
	h.append(int(k))
	s+=int(k)

l=1; r=s;
an=-1
while r>=l:
	m=(l+r)//2
	c=0
	for i in range(n):
		if (h[i]-b*m)%(a-b)==0:
			c=c+(h[i]-b*m)//(a-b)
		else:
			c=c+((h[i]-b*m)//(a-b)+1)
	if c<=m:
		an=m;
		r=m-1
	else:
		l=m+1
#print(r,l)
print(an)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
def judige(n):
    global h,a,b
    check = 0
    for i in range(len(h)):
        num = h[i]
        num -= b*n
        check += num//(abs(b-a)) if num % abs(b-a) == 0 else num//abs(b-a) + 1
    if check <= n:return True
    return False
inf = max(h)//b + 1
zero = 0
while True:
    num = (inf+zero)//2
    if inf-zero==1 or inf-zero==0:break
    if judige(num):inf = num
    else:zero = num
if judige(zero-2) and zero > 2:print(zero-2)
elif judige(zero-1) and zero > 1:print(zero-1)
elif judige(zero):print(zero)
else:print(inf)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
def judige(n):
    global h,a,b
    check = 0
    for i in range(len(h)):
        num = h[i]
        num -= b*n
        check += num//(abs(b-a)) if num % abs(b-a) == 0 else num//abs(b-a) + 1
    if check <= n:return True
    return False
inf = max(h)//b + 1
zero = 0
ruru = 10000000000000000000000000000000
while True:
    num = (inf+zero)//2
    if ruru == num:break
    ruru = num
    if judige(num):inf = num
    else:zero = num
if judige(zero-2) and zero > 2:print(zero-2)
elif judige(zero-1) and zero > 1:print(zero-1)
elif judige(zero):print(zero)
else:print(inf)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
h = [int(input()) for i in range(n)]
def judige(n):
    global h,a,b
    check = 0
    for i in range(len(h)):
        num = h[i]
        num -= b*n
        check += num//(abs(b-a)) if num % abs(b-a) == 0 else num//abs(b-a) + 1
    if check <= n:return True
    return False
inf = max(h)//b + 1
zero = 0
ruru = 10000000000000000000000000000000
while True:
    num = (inf+zero)//2
    if ruru == num:break
    ruru = num
    if judige(num):inf = num
    else:zero = num
if judige(zero):print(zero)
else:print(inf)

Submission status: Wrong Answer

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

ok=max(H)//B+1
ng=0
mid=(ok+ng)//2
while ok-ng>1:
  cntlive=0
  for h in H:
    h-=B*mid
    if h>0:
      cntlive+=(h+A-1)//A
  if cntlive<=mid:
    ok=mid
  else:
    ng=mid
  mid=(ok+ng)//2
print(ok)

Submission status: Wrong Answer

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

ok=max(H)//B+1
ng=0
mid=(ok+ng)//2
while ok-ng>1:
  cntlive=0
  for h in H:
    h-=B*mid
    if h>0:
      cntlive+=1
  if cntlive<=mid:
    ok=mid
  else:
    ng=mid
  mid=(ok+ng)//2
print(ok)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def ceil(x):
    return int((-x)//1*(-1))


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


def check(x, HP):
    cnt = 0
    for i in range(N):
        if HP[i]-B*x <= 0:
            break
        else:
            cnt += ceil((HP[i]-B*x)/diff)
    return cnt <= x


def solve2():
    HP = sorted(hp, reverse=True)
    mi = HP[0]//A
    ma = ceil(HP[0]/B)
    while mi <= ma:
        mid = (mi+ma)//2
        if check(mid, HP):
            ma = mid-1
        else:
            mi = mid+1
    print(mi)


def check2(x, hp):
    l = [a-B*x for a in hp]
    ret = 0
    for a in l:
        if a <= 0:
            continue
        else:
            ret += ceil(a/diff)
    return ret <= x


def solve3():
    mi = 0
    ma = N
    while mi <= ma:
        mid = (mi+ma)//2
        if check2(mid, hp):
            ma = mid-1
        else:
            mi = mid+1
    print(mi)


solve3()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int, input().split())
h=[int(input()) for i in range(n)]
r,l,c=0,10**9,10**9
while r<l-1:
    c=(r+l+1)//2
    h2=[i-b*c for i in h]
    h2=[i for i in h2 if i>0]
    count=0
    for i in h2:
        count+=-(-i//(a-b))
    if count<l:l=c
    else:r=c
print(l)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int, input().split())
h=[int(input()) for i in range(n)]
r,l,c=0,10**9,10**9
while r<l-1:
    c=r-((r-l)//2)
    h2=[i-b*c for i in h]
    h2=[i for i in h2 if i>0]
    count=0
    for i in h2:
        count+=-(-i//(a-b))
    if count<l:l=c
    else:r=c
print(c+1)

Submission status: Wrong Answer

Solution code:
def inpl(): return [int(i) for i in input().split()]

N,A,B = inpl()
C = A-B
h = [int(input()) for _ in range(N)]

lo = -(-sum(h)//((N-1)*B+A)) -1
hi = -(-sum(h)//A) 
while hi - lo > 1:
    me = (hi+lo)//2
    hprime = [h[i]-me*B for i in range(N) if h[i]-me*B >0]    
    hans = 0
    for j in hprime:
            hans += -(-j//C)
    if hans <= me:
        hi = me
    else:
        lo = me
print(hi)

Submission status: Wrong Answer

Solution code:
def inpl(): return [int(i) for i in input().split()]

N,A,B = inpl()
C = A-B
h = [int(input()) for _ in range(N)]

lo = -(-sum(h)//((N-1)*B+A))-1
hi = -(-sum(h)//A) 
while hi - lo > 1:
    me = (hi+lo)//2
    hprime = [h[i]-me*B for i in range(N) if h[i]-me*B >0]    
    hans = 0
    for j in hprime:
            hans += -(-j//C)
    if hans <= me:
        hi = me
    else:
        lo = me
print(hi)

Submission status: Wrong Answer

Solution code:
def inpl(): return [int(i) for i in input().split()]

N,A,B = inpl()
C = A-B
h = [int(input()) for _ in range(N)]

lo = -(-sum(h)//((N-1)*B+A))
hi = -(-sum(h)//A) 
while hi - lo > 1:
    me = (hi+lo)//2
    hprime = [h[i]-me*B for i in range(N) if h[i]-me*B >0]    
    hans = me
    for j in hprime:
            hans -= -(-j//C)
    if hans >= 0:
        hi = me
    else:
        lo = me
print(lo)

Submission status: Wrong Answer

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

left = 1
right = 0

n,a,b = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
    right += h[-1]//b+1

def check(t):
    cnt = 0
    for i in range(n):
        if h[i]-b*t>0:
            cnt += ceil((h[i]-b*t)/(a-b))
    return cnt<=t

while left+1<right:
    mid = (left+right)//2

    if check(mid):
        right = mid
    else:
        left = mid


print(right)

Submission status: Wrong Answer

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

left = 1
right = 0

n,a,b = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
    right += h[-1]//b+1

def check(t):
    cnt = 0
    for i in range(n):
        if h[i]-b*t>0:
            cnt += ceil((h[i]-b*t)/(a-b))
    return cnt<=t

while left<right:
    mid = left + (right-left)//2
    cl = check(left)
    cr = check(right)
    cm = check(mid)
    # print(left,mid,right,cl,cm,cr)

    if not cm and cr:
        left = mid+1
    elif not cl and cm:
        right = mid-1
    elif cl and cm and cr:
        break

print(mid)

Submission status: Wrong Answer

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

left = 1
right = 0

n,a,b = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
    right += h[-1]//b+1

def check(t):
    cnt = 0
    for i in range(n):
        if h[i]-b*t>0:
            cnt += ceil((h[i]-b*t)/(a-b))
    return cnt<=t

while left+1<right:
    mid = (left+right)//2
    cl = check(left)
    cr = check(right)
    cm = check(mid)
    # print(left,mid,right,cl,cm,cr)

    if not cm and cr:
        left = mid
    elif not cl and cm:
        right = mid

print(right)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
def fight(k):
    c = k
    for i in h:
        hp = i - B * k
        if hp > 0:
            c -= -(-hp // (A - B))
        if c < 0:
            return False
    return True

lo = 1
hi = 10 ** 9
while hi - lo > 1:
    mid = (lo + hi) // 2
    if fight(mid):
        hi = mid
    else:
        lo = mid
print(hi)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n, a, b = f.read_int_list()
    h = [f.read_int() for _ in xrange(n)]

    def check(num):
        s = 0
        for hi in h:
            s += (hi-num*b+(a-b-1))/(a-b)
        return s <= num

    ma = 10**9
    mi = 0

    while ma - mi > 1:
        mid = (ma+mi)/2
        if check(mid):
            ma = mid
        else:
            mi = mid

    return ma


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
ans = 0
while len(h) > 0:
    nexth = []
    lenh = len(h)
    hsum = sum(h)
    atleast = math.ceil(hsum/(A+B*(lenh-1)))
    ans += atleast
    count = atleast
    for i in range(lenh):
        checkh = h[i] - B*count
        if checkh <= 0:
            continue
        elif math.ceil(checkh/(A-B)) <= atleast:
            atleast -= math.ceil(checkh/(A-B))
        else:
            checkh -= (A-B)*atleast
            nexth.append(checkh)
    h = nexth
print(ans)

Submission status: Wrong Answer

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

tekis = list(sorted(teki))

while tekis != []:
    for i in range(len(tekis)):
        tekis[i] = tekis[i] - b
    
    k = max(tekis)
    tekis.remove(k)
    tekis.append(k + a- b)
    for i in range(len(tekis)):
        if tekis[i] <= 0:
            tekis[i] = 0
    while 0 in tekis:
        tekis.remove(0)
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# from numpy import array, sum

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

h_li = []

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

def all_beatable_check(k):
	# All enemy get B damage every time
	h_damaged = [h - B*k for h in h_li]
	# print(h_damaged)
	# A-B damage will be additionally given to enemies s.t. HP > 0
	ex_dmg = A - B
	h_ex_needed = [(h+ex_dmg-1) // ex_dmg if h >= ex_dmg else 0 for h in h_damaged]
	# print(h_ex_needed)
	# how many A-B damage is needed to beat all enemies
	hits_needed = sum(h_ex_needed)
	if hits_needed > k:
		return False
	else:
		return True

MIN_K = 1
MAX_K = max(h_li)

while True:
	if MIN_K == MAX_K:
		print(MIN_K)
		break
	# print(f"{MIN_K}-{MAX_K} {MIN_K + (MAX_K - MIN_K) // 2}")
	k = MIN_K + (MAX_K - MIN_K) // 2
	res = all_beatable_check(k)
	if res is True:
		MAX_K = k
	elif res is False:
		MIN_K = k + 1

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# from numpy import array, sum

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

h_li = []

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

def all_beatable_check(k):
	# All enemy get B damage every time
	h_damaged = [h - B*k for h in h_li]
	# print(h_damaged)
	# A-B damage will be additionally given to enemies s.t. HP > 0
	ex_dmg = A - B
	h_ex_needed = [(h+ex_dmg-1) // ex_dmg if h >= ex_dmg else 0 for h in h_damaged]
	# print(h_ex_needed)
	# how many A-B damage is needed to beat all enemies
	hits_needed = sum(h_ex_needed)
	if hits_needed > k:
		return False
	else:
		return True

MIN_K = 1
MAX_K = max(h_li)

while True:
	# print(f"{MIN_K}-{MAX_K} {MIN_K + (MAX_K - MIN_K) // 2}")
	k = MIN_K + (MAX_K - MIN_K) // 2
	res = all_beatable_check(k)
	if res is True:
		MAX_K = k
	elif res is False:
		MIN_K = k + 1
	if MIN_K == MAX_K:
		print(MIN_K)
		break

Submission status: Wrong Answer

Solution code:
def ceil(a, b):
    return (a+b-1)//b

def ok(a, b, hs, s):
    return sum(ceil(h-b*s, a-b) for h in hs) <= s

n, a, b = map(int, input().split())
hs = [int(input()) for _ in range(n)]

lo, hi = 0, 10**18
while(lo < hi):
    mi = (lo+hi)//2
    if(ok(a, b, hs, mi)):
        hi = mi
    else:
        lo = mi+1

print(lo)

Submission status: Wrong Answer

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

def enough(n):
    bomb = 0
    for h in src:
        if h <= B*n: continue
        h -= B*n
        bomb += math.ceil((h-1)/(A-B))
        if bomb > n: return False
    return True

#ok/ng: 中点が十分に大きいかどうか
ng = 0
ok = 10**9
while ok - ng > 1:
    m = (ok+ng) // 2
    if enough(m):
        ok = m
    else:
        ng = m
print(ok)

Submission status: Wrong Answer

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

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

#ok/ng: 中点が十分に大きいかどうか
ng = 0
ok = 10**9
while ok - ng > 1:
    m = (ok+ng) // 2
    if enough(m):
        ok = m
    else:
        ng = m
print(ok)

Submission status: Wrong Answer

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

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

#ok/ng: 中点が十分かどうか
ng = 0
ok = 10**9
while ok - ng > 1:
    m = (ok+ng) // 2
    if enough(m):
        ok = m
    else:
        ng = m
print(ok)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from bisect import bisect
def inpl(): return tuple(map(int, input().split()))

N, A, B = inpl()
D = A-B
H = []
res = 0
for _ in range(N):
    H.append(int(input()))

H = sorted(H)
l = sum(H) // (A+B*(N-1))
r = sum([h//A + (h%A>0) for h in H])

def judge(m):
    nH = [h - B*m for h in H]
    nH = nH[bisect(nH, 0):]
    if sum([h//D + (h%D>0) for h in nH]) <= m:
        return True
    else:
        return False

while True:
    mid = (l+r)//2
    if judge(mid):
        r = mid - 1
    else:
        l = mid + 1
    if l==r:
        print(l)
        break

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

C = A - B
T = 1

while 1:
    D = B * T
    S = H - D

    count = 0
    for i in S:
        if i > 0:
            count += math.ceil(i / C)

        if T <= count:
            break

    if T >= count:
        break
    else:
        T += 1

print(T)

Submission status: Wrong Answer

Solution code:
def is_finish(h_list):
    for h in h_list:
        if h > 0:
            return False

    return True


def get_min_count(d_list, h_list):
    A = d_list[0]
    B = d_list[1]

    ans = 0
    while not is_finish(h_list):
        h_list = sorted(h_list)
        h_list.reverse()

        cnt = int(h_list[0] / A)

        if cnt == 0:
            cnt = 1

        h_list[0] = h_list[0] - cnt*A

        for i in range(1, len(h_list)):
            h_list[i] = h_list[i] - B*cnt

        ans += cnt

    return ans


if __name__ == '__main__':
    N, A, B = [int(i) for i in input().split()]
    h_list = []
    for i in range(N):
        h_list.append(int(input()))
    ans = get_min_count([A, B], h_list)
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np


if __name__ == "__main__":
    N, A, B = map(int, raw_input().split())
    health = [int(raw_input()) for i in range(N)]

    target = max(health)
    attack = 0
    while target > 0:
        target_index = health.index(target)

        health = [h - B for h in health]
        health[target_index] -= (A-B)
        attack += 1
        target = max(health)
        print target
    print attack

Submission status: Wrong Answer

Solution code:
(N, A, B) = [int(x) for x in input().split(" ")]
hs = [int(input()) for x in range(N)]
num = 0
ds = A - B
while hs[-1] > 0:
    hs.sort()
    for i in range(len(hs)):
        hs[i] -= B
    hs[-1] -= ds
    num += 1
print(num)

Submission status: Wrong Answer

Solution code:
from math import ceil

n, a, b = map(int, input().rstrip("\n").split(" "))
diff = a - b

h = []
total = 0
for i in range(n):
  value = int(input()) 
  h.append(value)

total = sum(h)

h.sort()

right = ceil(total // b)  + len(h)
center = right // 2
left = 0

def check(b_count, h):
   b_total = b * b_count
   count = 0
   for value in h:
     remain = value - b_total
     if remain > 0:
       count += ceil( remain  /  diff)
       if count > b_count:
         break
   return count - b_count

result = 0
while left < right:
   #print(left,right)
   center = (left + right) // 2
   result = check(center, h)
   if result < 0:
     right = center - 1
   elif result > 0:
     left= center + 1
   if result == 0:
     break
#print(left,center,right)
print(center)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
extra_damage = a - b
h = [int(input()) for i in range(n)]
# h.sort()
INF = sum(h)
l = 0
r = INF


def widespread(bomb):
    base = b * bomb
    for hi in h:
        if hi - base > 0:
            bomb -= (hi - base + extra_damage - 1) // extra_damage
    return bomb >= 0

while l+1 < r:
    m = (l+r)//2
    print(m)
    if widespread(m):
        r = m
    else:
        l = m
print(r)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
extra_damage = a - b
h = [int(input()) for i in range(n)]
h.sort()
INF = sum(h)
l = 0
r = INF


def widespread(bomb):
    base = b * bomb
    for hi in h:
        bomb -= (hi-base + extra_damage - 1)//extra_damage
    return bomb >= 0

while l+1 < r:
    m = (l+r)//2
    if widespread(m):
        r = m
    else:
        l = m
print(r)

Submission status: Wrong Answer

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

l = input().split()
N = int(l[0])
A = int(l[1])
B = int(l[2])

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

count = 0
check = 0
while(True):
	HP.sort()
	print(HP)

	for i in range(N):
		if i == N-1:
			HP[i] = HP[i] - A
			count = count + 1
		else:
			HP[i] = HP[i] - B

	for i in range(N):
		if HP[N-1] <= 0 and HP[N-2] <= 0:
			check = 1

	if check == 1:
		break

print(count)

Submission status: Wrong Answer

Solution code:
from math import ceil


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

l, r = (h[0] // A + 1), (h[-1] // B + 1)
while l + 1 < r:
    m = (l + r) // 2
    total = 0
    enough = True
    for hi in h:
        total += max(0, ceil((hi - B * m) / (A - B)))
        if total > m:
            enough = False
            break
    if enough:
        r = m
    else:
        l = m

print(r)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
s=[int(input()) for _ in range(n)]
u=max(s)//b+1
l=0
while l+1<u:
    m=(u+l)//2
    if m<sum((h-b*m+a-b-1)//(a-b) for h in s):
        l=m
    else:
        u=m
print(u)

Submission status: Wrong Answer

Solution code:
import math
N,A,B = map(int,input().split())
H = [int(input()) for i in range(N)]
Hs = sum(H)
c = A - B
M = math.ceil(max(H) / B) + 1

m = math.ceil(max(H) / A)

while M - m > 1:
	n = (M + m) // 2
	H2 = [math.ceil((H[i] - n * B) / c) for i in range(N) if H[i] - n * B > 0]
	cnt = sum(H2)
	if cnt > n:
		m = n
	elif cnt == n:
		M = n
		break
	else:
		M = n
print(M)

Submission status: Wrong Answer

Solution code:
import math
N,A,B = map(int,input().split())
H = [int(input()) for i in range(N)]
Hs = sum(H)
c = A - B
M = math.ceil(max(H) / B)

m = math.ceil(max(H) / A)

while M - m > 1:
	n = (M + m) // 2
	H2 = [math.ceil((H[i] - n * B) / c) for i in range(N) if H[i] - n * B > 0]
	cnt = sum(H2)
	if cnt > n:
		m = n
	elif cnt == n:
		M = n
		break
	else:
		M = n
print(M)

Submission status: Wrong Answer

Solution code:
#coding:utf-8

import math

def enough(A, B, h_list, T):
    h_list = filter(lambda x: (x - B * T) > 0, h_list)
    h_list = map(lambda x : x - B * T, h_list)

    exp_num = 0
    for val in h_list:
        exp_num += math.ceil(val / (A - B))

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

def binary_search(A, B, h_list, T_min, T_max):
    if T_min == T_max:
        return T_min
    else:
        T_mid = T_min + (T_max - T_min) // 2
        if enough(A, B, h_list, T_mid):
            return binary_search(A, B, h_list, T_min, T_mid)
        else:
            return binary_search(A, B, h_list, T_mid + 1, T_max)

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

    h_list = []
    for i in range(N):
        h_list.append(int(input()))

    T_max = math.ceil(sum(h_list) / A)
    print(binary_search(A, B, h_list, 0, T_max))

Submission status: Wrong Answer

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

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

low = sum(H)//(len(H)*B+A-B) - 1
high = max(H)//B+1
print(low, high)

d = A-B
ceildiv = lambda x,y: -(-x//y)

while low + 1 < high:
  mid = (low+high)//2
  offset = mid*B
  cnt = sum(max(ceildiv(h - offset, d),0) for h in H)
  if cnt > mid:
    low = mid
  else:
    high = mid

print(high)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
D = A - B

H = [int(input()) for _ in range(N)]

def f(n):
    needed_attacks = 0
    for h in H:
        r = h - B * n
        if r < 0:
            r = 0

        if r % D == 0:
            needed_attacks += r // D
        else:
            needed_attacks += r // D + 1

    return needed_attacks <= n

s = 0
e = max(H) // B

while e - s > 1:
    m = (s + e) // 2
    if f(m):
        e = m
    else:
        s = m

print(e)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
D = A - B

H = sorted([int(input()) for _ in range(N)], reverse=True)

def f(n):
    needed_attacks = 0
    for h in H:
        r = h - B * n
        if r < 0:
            r = 0

        if r % D == 0:
            needed_attacks += r // D
        else:
            needed_attacks += r // D + 1

    return needed_attacks <= n

s = 0
e = H[-1] // B + 1

while e - s > 1:
    m = (s + e) // 2
    if f(m):
        e = m
    else:
        s = m

print(e)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
hs = [None]*n
kill_b = [None]*n
all_hp = 0
all_killb = 0
for i in range(n):
    hs[i] = int(input())
    # all_hp += hs[i]
    # kill_b[i] = hs[i] // b
    # if((hs[i] % b) != 0):
    #     kill_b[i] += 1
    # all_killb += kill_b[i]
# hs.sort()
max_hp = max(hs)
ret = 0
if(a == b):
    ret = max_hp // a
    if((max_hp % a) != 0):
        ret += 1
    else:
        pass
else:
    ab = a - b
    right = max_hp // b
    if((max_hp % b) == 0):
        right += 1
    left = 1
    while right != left:
        middle = (right + left) // 2
        # print([left, right, middle])
        all_a = 0
        for x in hs:
            nokori = x - (b * middle)
            if(nokori > 0):
                num_a = nokori // ab
                if(x > num_a * a + (middle - num_a) * b):
                    num_a += 1
                all_a += num_a
        if(all_a <= middle):
            right = middle
        else:
            left = middle + 1
    ret = right
    # for i in range(hs[-1] // b):
        # flag = False
        # for j in range(n):
        #     ret += 1
        #     base_height = (ret * b) + (i * (a-b))
        #     #print(base_height)
        #     if((j == n-1) or (hs[-(j+2)] <= (base_height))):
        #         break
        # max_height = (ret * b) + ((i + 1) * (a-b))
        # if(max_height >= hs[-1]):
        #     break
print(ret)