Problem:


Score : 400 points

Problem Statement

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

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

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

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

Constraints

All input values are integers.

1 ≤ N ≤ 10^5

1 ≤ B < A ≤ 10^9

1 ≤ h_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N A B
h_1
h_2
:
h_N

Output

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

Sample Input 1

4 5 3
8
7
4
2

Sample Output 1

2

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

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

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

Sample Input 2

2 10 4
20
20

Sample Output 2

4

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

Sample Input 3

5 2 1
900000000
900000000
1000000000
1000000000
1000000000

Sample Output 3

800000000



Sample input:
4 5 3
8
7
4
2


Sample output:
2

Submission status: Wrong Answer

Solution code:
import sys,bisect as bs,collections as cl,heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n,a,b = m()

h = []

for i in range(n):
    h.append(onem())

h.sort(reverse = True)

l = 1
r = h[0]

while l != r:
    x = (l+r)//2
    ct = 0
    for i in range(n):
        ct += ((a-b-1) + max(0,h[i]-b*x))//(a+b)
    if ct > x:
        l += x+1
    else:
        r = x
print(l)

Submission status: Wrong Answer

Solution code:
import sys
import math
def input():
    return sys.stdin.readline()[:-1]

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

def check(m):
    tmp=0
    for i in range(n):
        tmp+=math.ceil((h[i]-b*m)/(a-b))
    if tmp<=m:
        return True
    else:
        return False

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

Submission status: Wrong Answer

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

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

left = 0
right = 10000000000

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

Submission status: Wrong Answer

Solution code:
n,a,b,*H=map(int,open(0).read().split())
l,r=1,10**9
while r-l>1:
	x=0
	m=(l+r)//2
	s=m*b
	for h in H:
		x-=min(0,(h-s)//-(a-b))
	if x>m:
		l=m
	else:
		r=m
print(r)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def solve(N: int, A: int, B: int, h: "List[int]"):
    tot = sum(h)

    def isOK(index):
        base = B*index
        sub = A-B
        counter = 0
        for hh in h:
            if hh > base:
                counter += int(math.ceil((hh-base)/sub))
            if index < counter:
                return False

        return index >= counter

    ng = 1
    ok = 2*tot//(N*B) + 1
    # print(ng, ok)

    while abs(ok - ng) > 1:
        mid = (ok + ng)//2
        if isOK(mid):
            ok = mid
        else:
            ng = mid
    print(ok)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, h)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def solve(N: int, A: int, B: int, h: "List[int]"):
    tot = sum(h)

    def isOK(index):
        base = B*index
        sub = A-B
        counter = 0
        for hh in h:
            if hh > base:
                counter += int(math.ceil((hh-base)/sub))
            if index < counter:
                return False

        return index >= counter

    ng = tot//(N*A)
    ok = tot//(N*B) + 1
    # print(ng, ok)

    while abs(ok - ng) > 1:
        mid = (ok + ng)//2
        if isOK(mid):
            ok = mid
        else:
            ng = mid
    print(ok)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, h)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,A,B = inputMap()
    h = []
    A_cnt = 0
    B_cnt = 0
    over_cnt = 0
    A_ovre_arr = []
    for i in range(N):
        tmp = inputInt()
        h.append(tmp)
        
        if tmp <= B:
            B_cnt += 1
        elif tmp <= A:
            A_cnt += 1
            A_ovre_arr.append(tmp)
        else:
            over_cnt += 1
            A_ovre_arr.append(tmp)
            
    if over_cnt == 0 and A_cnt <= 1:
        print(1)
        sys.exit()
    
    saitei = -(-max(A_ovre_arr) // B)
    saikou = -(-max(A_ovre_arr) // A)
    
    if saitei == saikou:
        print(saitei)
        sys.exit()
        
    print(saikou)
        
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

C = A-B
j = sum([h//C for h in H])
H_broken = []
for i, m in enumerate(sorted([h%C for h in H])):
    h_broken = m+(j//N+1)*C if i<j%N else m+(j//N)*C
    H_broken.append(h_broken)

H_broken = H_broken[j%N-1::-1] + H_broken[-1:j%N-1:-1]

D = B*N+C
M = (H_broken[-1]//D)*N

for i in range(N):
    if H_broken[i]%D <= i*B: break
    M += 1

print(M)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
h = [int(input()) for _ in range(n)]
d = a-b
l = 0
r = 10**9+1
ans = r


def check(num):
    global h
    global d
    global b
    cnt = 0
    for i in h:
        if i>b*num:
            cnt+= (i-b*num)//d
            if cnt%d:
                cnt+=1
    return cnt<=num


while r>=l:
    mid = (r+l)//2
    if check(mid):
        r = mid-1
        ans = min(ans,mid)
    else:
        l = mid+1
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def judge(x):
  res = np.ceil((hp - B*x)/(A-B))
  cnt = res[res > 0].sum()
  if cnt <= x:
    return True
  else:
    return False

# 二分探索 #
def nibutan(n):
  left = 0
  right = n
  while left+1 != right:
    middle = (left+right)//2
    if judge(middle):
      right = middle
    else:
      left = middle
  return right

N,A,B = IL()
hp = np.array([I() for i in range(N)])
hp.sort()
n = hp[-1]//B

ans = nibutan(n)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

def hersCode(N):
  ng = -1
  ok = N
  while ok -  ng > 1:
    mid = (ok + ng) // 2
    if judge(mid):
      ok = mid
    else:
      ng = mid
  return ok

def judge(x):
  cnt = 0
  for i in h:
    cnt += math.ceil((i - x * B) / (A - B))
  return cnt <= x


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

print(hersCode(10 ** 9))

Submission status: Wrong Answer

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

def test(n):
    x = H - n*B
    x[x<0] = 0
    return x.sum() <= n*(A-B)

left = 0
right = 10**9

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

Submission status: Wrong Answer

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

def test(n):
    x = H - B*n
    x[x<0] = 0
    return x.sum() <= n*(A-B)

left = 0
right = 10**9

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N, A, B = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
H = np.array(h)
ans = 0
while len(H[H>0]):
    H = H - B
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, A, B = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
H = np.array(h)
ans = 0
while len(H[H>0]):
    H = H - B
    H[np.argmax(H)] -= A
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def bsearch_int(init_ng, init_ok, cond):
    ng = init_ng
    ok = init_ok
    while(abs(ok - ng) > 0):
        mid = math.floor(abs(ok + ng)/2)
        if cond(mid):
            ok = mid
        else:
            ng = mid + 1
    return ok if ok != init_ok else -1

def condition(cnt, N, A, B, hs):
    basedmg = B*cnt
    diff = A - B
    diffcnt = 0
    for h in hs:
        if h < basedmg:
            break
        else:
            diffcnt += math.ceil((h-basedmg)/diff)
    if diffcnt > cnt:
        return False
    else:
        return True

import functools
def resolve():
    N, A, B = list(map(int, input().split(" ")))
    hs = [int(input()) for i in range(N)]
    hs.sort(reverse=True)
    print(bsearch_int(0, math.ceil(hs[0]/B), functools.partial(condition, N=N, A=A, B=B, hs=hs)))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import math
def bsearch_int(init_ng, init_ok, cond):
    ng = init_ng
    ok = init_ok
    while(abs(ok - ng) > 1):
        mid = math.floor(abs(ok + ng)/2)
        if cond(mid):
            ok = mid
        else:
            ng = mid + 1
    return ok if ok != init_ok else -1

def condition(cnt, N, A, B, hs):
    basedmg = B*cnt
    diff = A - B
    diffcnt = 0
    for h in hs:
        if h < basedmg:
            break
        else:
            diffcnt += math.ceil((h-basedmg)/diff)
    if diffcnt > cnt:
        return False
    else:
        return True

import functools
def resolve():
    N, A, B = list(map(int, input().split(" ")))
    hs = [int(input()) for i in range(N)]
    hs.sort(reverse=True)
    print(bsearch_int(0, math.ceil(hs[0]/B), functools.partial(condition, N=N, A=A, B=B, hs=hs)))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import math
def bsearch_int(init_ng, init_ok, cond):
    ng = init_ng
    ok = init_ok
    while(abs(ok - ng) > 1):
        mid = math.floor(abs(ok + ng)/2)
        if cond(mid):
            ok = mid
        else:
            ng = mid
    return ok if ok != init_ok else -1

def condition(cnt, N, A, B, hs):
    basedmg = B*cnt
    diff = A - B
    diffcnt = 0
    for h in hs:
        if h < basedmg:
            break
        else:
            diffcnt += math.ceil((h-basedmg)/diff)
    if diffcnt > cnt:
        return False
    else:
        return True

import functools
def resolve():
    N, A, B = list(map(int, input().split(" ")))
    hs = [int(input()) for i in range(N)]
    hs.sort(reverse=True)
    print(bsearch_int(0, math.ceil(hs[0]/B), functools.partial(condition, N=N, A=A, B=B, hs=hs)))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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


ans=chk=0
d=[]
for i in range(n):
    x=int(input())
    heapq.heappush(d,-x)
if n==1:
    print((d[0]+a-1)//a)
    exit()
u=1
if a-b==1 and d[0]<-100000:
    a*=10000
    b*=10000
    u=10000
c=a-b


while 1:
    t=heapq.heappop(d)
    if t+chk>=0: break
    ans+=1
    p=(abs(t-d[0])+c-1)//c
    p=max(1,p)
    t+=c*p
    chk+=b*p
    heapq.heappush(d,t)
print(ans*u)

Submission status: Wrong Answer

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


ans=chk=0
d=[]
for i in range(n):
    x=int(input())
    heapq.heappush(d,-x)
if n==1:
    print((d[0]+a-1)//a)
    exit()
u=1
if a-b==1 and d[0]<-10000:
    a*=10000
    b*=10000
    u=10000
c=a-b


while 1:
#for i in range(5):
    t=heapq.heappop(d)
    if t+chk>=0: break
    ans+=1
    p=(abs(t-d[0])+c-1)//c
    p=max(1,p)
    t+=c*p
    chk+=b*p
    heapq.heappush(d,t)
print(ans*u)

Submission status: Wrong Answer

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


def bisect_left_callable(fn, x, lo, hi):
    """
    lo から hi-1 のうち、fn の結果が x 以上となる、最も左の値
    bisect.bisect_left と同じ
    https://docs.python.org/ja/3/library/bisect.html
    :param callable fn:
    :param x:
    :param int lo: 最小値
    :param int hi: 最大値 + 1
    :return: lo <= ret <= hi
    """
    while lo < hi:
        mid = (lo + hi) // 2
        if fn(mid) < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


N, A, B = list(map(int, sys.stdin.readline().split()))
H = [int(sys.stdin.readline()) for _ in range(N)]
H = np.array(H)


def can_clear(count):
    # 倒せるなら 1、倒せないなら 0
    # 爆発の回数を決めたときにそれぞれ何回中心に選べばいいか
    center_counts = np.ceil((H - count * B) / (A - B))
    return int(center_counts.sum() <= count)


cnt = bisect_left_callable(can_clear, 1, lo=1, hi=10 ** 10)
print(cnt)

Submission status: Wrong Answer

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


def bisect_left_callable(fn, x, lo, hi):
    """
    lo から hi-1 のうち、fn の結果が x 以上となる、最も左の値
    bisect.bisect_left と同じ
    https://docs.python.org/ja/3/library/bisect.html
    :param callable fn:
    :param x:
    :param int lo: 最小値
    :param int hi: 最大値 + 1
    :return: lo <= ret <= hi
    """
    while lo < hi:
        mid = (lo + hi) // 2
        if fn(mid) < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


N, A, B = list(map(int, sys.stdin.readline().split()))
H = [int(sys.stdin.readline()) for _ in range(N)]

H = np.array(H)

# B 何回で倒せるか
b_counts = np.ceil(H / B)


def can_clear(count):
    # 倒せるなら 1、倒せないなら 0
    # 爆発の回数を決めたときにそれぞれ何回中心に選べばいいか
    center_counts = np.ceil((H - count * B) / (A - B))
    return int(center_counts.sum() <= count)


cnt = bisect_left_callable(can_clear, 1, lo=0, hi=10 ** 9)
print(cnt)

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph)
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse import csr_matrix

from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！

def main():
    n,a,b,*h=map(int,open(0).read().split())
    h=array(h)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    from heapq import heappop, heappush, heappushpop
    from math import floor,ceil,sqrt,factorial
    """O(max(h)*log(n))なので無理
    N, A, B = MI()
    H = []
    #heapで最大を持ち続けたいのでマイナスにして格納するよ!(popするときは符号反転させる)
    for _ in range(N):
        h=I()
        heappush(H, -h)
    C = A - B
    
    for i in range(1, -H[0] // B + 2):
        heappushpop(H, H[0] + C)
        print(H[0],i,i*B)
        if - H[0] <= i * B:
            print(i)
            break
            """
    #操作回数で二分探索
    N, A, B = MI()
    H = LIN(N)
    C=A-B

    def is_ok(n):
        cnt = 0
        for h in H:
            cnt+=ceil((h-n*B)/C)
        return cnt <= n
        
    ok = 10 ** 9 // B + 1
    ng=0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    print(ok)

        
        
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def can_eliminate(n): #O(N)
  H_ = [((h-B*n)+A-B-1)//(A-B) for h in H if h>B*n]
  if sum(H_)<=n:
    #print('can eliminate by ' + str(n) +'times')
    return True
  else:
    #print('can not eliminate by ' + str(n) +'times')
    return False
    
def binary_search(l,r): #r:inclusive
  #print('search between ' + str((l,r)))
  if r==l+1:
    if can_eliminate(r):
      return r
    else:
      return l
  c = (l+r)//2
  if can_eliminate(c):
    return binary_search(l,c)
  else:
    return binary_search(c,r)
  
print(binary_search(1, (sum(H)+2*B+1)//B))

Submission status: Wrong Answer

Solution code:
from math import ceil

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


# 二分法により解を求める
def bis(p, ok, ng):
    mid = (ok + ng) // 2
    return (
        ok if abs(ok - ng) == 1 else
        bis(p, mid, ng) if p(mid) else
        bis(p, ok, mid)
    )


ans = bis(
    lambda k: sum(ceil((x - k * B) / (A - B)) for x in h) <= k,
    10**10,
    0
)

# 出力
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

#print(h)

MAX=10**9
MIN=1
MID=(MAX+MIN)//2
for i in range(100):
    if MAX-MID<=1:
        print(MAX)
        exit()
    else:
        X=0
        for j in range(N):
            if h[j]>B*MID:
                if (h[j]-B*MID)%A==0:
                    X+=(h[j]-B*MID)
                else:
                    X+=(h[j]-B*MID)+1
        if X>MID:
            MIN=MID
            MID=(MAX+MIN)//2
        else:
            MAX=MID
            MID=(MAX+MIN)//2

Submission status: Wrong Answer

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

def nearest(x):
    if x - int(x)>=0.5:
        return int(x)+1
    else:
        return int(x)

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

    M = roof(m / b)
    
    x = M
    y = 0
    
    if x == 1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            x = half
        else:
            y = half
        #print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

for i in range(0,n):
    h[i] = int(input())
print(nearest(ans(n,a,b,h)))

Submission status: Wrong Answer

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

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

def judge(k):
    cnt = 0
    for h in H:
        cnt += -(-(h-k*B)//(A-B))
    if cnt <= k:
        return True
    return False
def biserch(ok,ng,judge):
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        if judge(mid):
            ok = mid
        else:
            ng = mid
    return ok

ans = biserch(max(H),-1,judge)
print(ans)

Submission status: Wrong Answer

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

def is_eliminatable(num):
    avr_d = num * b
    count = 0
    for item in h:
        count += (item - avr_d) // alpha_d
        if (item - avr_d) % alpha_d != 0:
            count += 1 
        if count > num:
            return False
    return True

r = 10**15
l = -1 
while (r-l > 1):
    mid = l + (r - l) // 2
    if is_eliminatable(mid):
        r = mid
    else:
        l = mid
print(r)

Submission status: Wrong Answer

Solution code:
import heapq
import math
n, a, b = [int(item) for item in input().split()]
h = []
for i in range(n):
    h.append(int(input()))
alpha_d = a-b

def is_eliminatable(num):
    avr_d = num * b
    count = 0
    for item in h:
        count += math.ceil((item - avr_d) / alpha_d)
        if count > num:
            return False
    return True

r = 10**15 - 1
l = -1 
while (r-l > 1):
    mid = l + (r - l) // 2
    if is_eliminatable(mid):
        r = mid
    else:
        l = mid
print(r)

Submission status: Wrong Answer

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

d = A-B

def judge(k):
    cnt = 0
    remain = [h-k*B for h in H]
    for r in remain:
        cnt += -(-r // d)
    if cnt <= k:
        return True
    else:
        return False

def biserch(ok,ng,judge):
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        if judge(mid):
            ok = mid
        else:
            ng = mid
    return ok

ans = biserch(10**9,-1,judge)
print(ans)

Submission status: Wrong Answer

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

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

    M = roof(m / b)
    
    x = M
    y = 0
    
    if x == 1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            x = half
        else:
            y = half
        #print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

for i in range(0,n):
    h[i] = int(input())
print(int(ans(n,a,b,h)))

Submission status: Wrong Answer

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

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

    M = roof(m / b)
    
    x = M
    y = 0
    
    if x == 1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            x = half
        else:
            y = half
        print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

for i in range(0,n):
    h[i] = int(input())
print(int(ans(n,a,b,h)))

Submission status: Wrong Answer

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

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

    M = int(m / b)
    
    x = M
    y = 0
    
    if x ==1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            y = half
        else:
            x = half
        #print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

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

print(ans(n,a,b,h))

Submission status: Wrong Answer

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

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

    M = int(m / b)
    
    x = M
    y = 0
    
    if x ==1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            x = half
        else:
            y = half
        #print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

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

print(ans(n,a,b,h))

Submission status: Wrong Answer

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

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

    M = roof(m / b)
    
    x = M
    y = 0
    
    if x ==1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            x = half
        else:
            y = half
        #print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

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

print(ans(n,a,b,h))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
    
def f(x):
    s = sum([- (- max(0, h - x * B) / (A - B)) for h in H])
    if s <= x:
        return True
    else:
        return False
    
l = 0
r = 10 ** 9 + 7
while r - l > 1:
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m
    # print(r, l, m)
        
print(r)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
    
def f(x):
    s = sum([- (- max(0, h - x * B) / (A - B)) for h in H])
    if s <= x:
        return True
    else:
        return False
    
l = 0
r = 10 ** 9 + 7
while l < r:
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m + 1
    # print(r, l, m)
        
print(r)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
    
def f(x):
    s = sum([math.ceil(max(0, h - x * B) / (A - B)) for h in H])
    if s <= x:
        return True
    else:
        return False
    
l = 0
r = 10 ** 9 + 7
while r - l > 1:
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m
    # print(r, l, m)
        
print(m)