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
def input():
    return sys.stdin.readline()[:-1]
N,A,B=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort(reverse=1)
l,r=1,10**9
k=A-B
while l+1<r:
    m=(r-l)//2+l
    t=m*B
    c=0
    for i in h:
        if i>t:
            c+=-((-i+t)//k)
     #       if c>m:
      #          break
        else:
            break
    if c>m:
        l=m
    else:
        r=m
print(r)

Submission status: Wrong Answer

Solution code:
#A
if False:
    N=int(input())
    E=[int(i) for i in input().split()]
    E.sort()
    s=sum(E)
    if E[-1]<s-E[-1]:
        print('Yes')
    else:
        print('No')
#B
if False:
    N=int(input())
    fac=[]
    for i in range(1,10**6+1000):
        if N%i==0:
            fac.append((i,N//i))
    ans=10**19
    for l,r in fac:
        ans=min(l-1+r-1,ans)
    print(ans)
  
#C
if False:
    N=int(input())
    S=[input() for _ in range(N)]
    march=list('MARCH')
    nam=[[] for _ in range(len(march))]
    for s in S:
        if s[0] in march:
            nam[march.index(s[0])].append(s)
    ans=0
    for i in range(5):
        for j in range(i+1,5):
            for k in range(j+1,5):
                ans+=len(nam[i])*len(nam[j])*len(nam[k])
    print(ans)

#D
if False:
    import sys

    if sys.getrecursionlimit()<10**7:
        sys.setrecursionlimit(10**7)

    N=int(input())
    ver=[[] for _ in range(N)]
    for _ in range(N-1):
        u,v,W=map(int,input().split())
        ver[u-1].append((v-1,W))
        ver[v-1].append((u-1,W))
    his=[-1 for _ in range(N)]

    def dfs(i,col):
        his[i]=col
        for j,w in ver[i]:
            if his[j]==-1:
                if w%2==0:
                    dfs(j,col)
                else:
                    dfs(j,(col+1)%2)

    dfs(0,0)            
    for i in range(N):
        print(his[i])

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

def eno(T):
    nee=0
    td=B*T
    dd=A-B
    for h in H:
        if h-td>0:
            nee+=(h-td)//dd
    return nee<=T

l,r=0,10**9+7
while l+1<r:
    mid=(l+r)//2
    if eno(mid):
        r=mid
    else:
        l=mid
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)]
d = A - B


l = 1
r = max(h)
while(l+1 < r):
    m = (l+r)//2
    t = m*B
    count = 0
    for x in h:
        if x > t:
            count += math.ceil((x-t)//d)
    if count <= m:
        r = m
    else:
        l = m


print(r)

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    H.sort()
    TotalH = sum(H)
    low = 0; high = 10 ** 20
    while high - low > 1:
        mid = (low + high) // 2
        explosion = B * mid
        direct = 0
        for h in H:
            direct += (h - explosion) // (A - B)
            if (h - explosion) // (A - B) > 0: direct += 1
        if direct <= mid: high = mid
        else: low = mid
    print(high)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    H.sort()
    TotalH = sum(H)
    low = 0; high = 10 ** 20
    while high - low > 1:
        mid = (low + high) // 2
        explosion = B * mid
        direct = 0
        for h in H:
            direct += (h - explosion - 1) // (A - B) + 1
        if direct <= mid: high = mid
        else: low = mid
    print(high)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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
ans=0
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: Wrong Answer

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
ans=0
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: Wrong Answer

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B=MI()
    h=[0]*N
    for i in range(N):
        h[i]=I()
        
    def ch(X):
        #X回で達成できるか?
        temp=0
        for i in range(N):
            hp=h[i]-X*B
            temp+=(hp+A-B-1)//(A-B)
        if temp<=X:
            return True
        return False
    
    ng=0
    ok=10**9
    
    while abs(ok-ng)>1:
        x=(ok+ng)//2
        if ch(x):
            ok=x
        else:
            ng=x
    print(ok)
        

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(x):
    k = b*x
    sm = 0
    for i in range(n):
        sm += max(0, (h[i]-k+c-1)//c)
    #ddprint(f"foo {x} sm {sm}")
    return (sm<=x)

n,a,b = inm()
h = []
for i in range(n):
    h.append(inn())
c = a-b
mn = 0
mx = (max(h)+c-1)//c
while mx>mn+1:
    mid = (mx+mn)//2
    if foo(mid):
        mx = mid
    else:
        mn = mid
print(mx)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def f(n):
    cnt = 0
    for h in H:
        x = (h-B*n)//(A-B) + min((h-B*n)%(A-B), 1)
        cnt += x
    if cnt <= n:
        return True
    else:
        return False
        
l = 0
r = 10**9
while r-l > 1:
    m = (r+l)//2
    if f(m):
        r = m
    else:
        l = m
        
if f(l):
    print(l)
else:
    print(r)

Submission status: Wrong Answer

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

h_sum=sum(h)

ok=10**9
ng=0
while abs(ok-ng)>1:
 mid=(ok+ng)//2

 l=[i-(mid*b) for i in h]
 cnt=0
 for j in l:
  if j%(a-b)==0:
   cnt+=j//(a-b)
  else:
   cnt+=j//(a-b)+1

 if cnt<=mid:
  ok=mid
 else:
  ng=mid

print(ok)

Submission status: Wrong Answer

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

def mainasu(n):
    return n - b

sort_h = sorted(h,reverse=True)
while max(sort_h) > 0:
    sort_h = sorted(h,reverse=True)
    for i in range(n):
        if i == sort_h[0]:
            i -= a
        else:
            i -= b
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
u = 10**9
d = 0
N,A,B = map(int,input().split())
s = A - B
H = []
import math
for i in range(N):
    h = int(input())
    H.append(h)
for i in range(40):
    x = (u+d)//2
    a = 0
    for j in range(N):
        h = H[j]
        h -= B*x
        if h > 0:
            a += math.ceil(h//s)
    if a > x:
        d = x
    else:
        u = x
print(u)

Submission status: Wrong Answer

Solution code:
u = 10**18
d = 0
N,A,B = map(int,input().split())
s = A - B
H = []
import math
for i in range(N):
    h = int(input())
    H.append(h)
for i in range(50):
    x = (u+d)//2
    a = 0
    for j in range(N):
        h = H[j]
        h -= B
        if h > 0:
            a += math.ceil(h//A)
    if a > x:
        d = x
    else:
        u = x
print(u)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
h=[int(input())for _ in range(n)]
ok=10**9
ng=0
while ng+1!=ok:
  mid=(ok+ng)//2
  s=0
  for i in h:
    j=i-mid*b
    s+=0--j//(a-b)
  if s>mid:ng=mid
  else:ok=mid
print(ok)

Submission status: Wrong Answer

Solution code:
N, A, B, *H = map(int, open(0).read().split())

def is_ok(K):
    return sum(-(-(h - B * K) // (A - B)) for h in H) <= K

ng, ok = 0, 10 ** 18
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

ng = 0
ok = 10**9+1

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 += (ceil(h_copy[i]/(A-B)))
    return cnt <= x


while ng+1 != ok:
    m = (ok+ng)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

ng = 0
ok = 10**9

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 += (ceil(h_copy[i]/(A-B)))
    return cnt <= x


while ng+1 != ok:
    m = (ok+ng)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
H = sorted([int(input()) for _ in range(n)], reverse=True)
c = a - b
def is_can(x):
  s = 0
  d = b*x
  s = 0
  for h in H:
    s -= -(h-d) // c
  if s <= x:
    return True
  return False

ng = 0
ok = -(-H[0]//b)
while ok - ng > 1:
  m = (ok+ng)//2
  if is_can(m):
    ok = m
  else:
    ng = m
print(ok)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
read = sys.stdin.read

N, A, B, *h = map(int, read().split())

h = np.array(h, np.int64)

# 2部探索する。n回の爆発で魔物をすべて倒せるか否や
l = 0
r = max(h) // B
a = A - B
while l + 1 < r:
    mid = (l + r) // 2
    w = B * mid
    tmp = h - w
    tmp = tmp[tmp > 0]
    tmp = tmp // a + np.minimum(tmp % a, 1)
    if tmp.sum() <= mid:
        r = mid
    else:
        l = mid

print(r)

Submission status: Wrong Answer

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

h = []
for _ in range(n):
  h.append(int(input()))
           
total = sum(h)

size = len(set(h))
print(math.ceil(total/(a+(n-1)*b))) if size != 1 else print(math.ceil(total/(a+(n-1)*b))+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
H=[int(input()) for _ in range(n)]
r=10**10
l=1
while r-l>1:
    k=(l+r)//2
    if sum( max(0,(h-k*b-1)//(a-b)+1) for h in H)>k:
        l=k
    else:
        r=k

print(r)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, a, b = LI()
H = IR(n)
ok = 10 ** 9
ng = 0
while ok > ng + 1:
    mid = (ok + ng) // 2
    ret = 0
    for h in H:
        remain = h - b * mid
        if remain > 0:
            ret += remain // (a - b) + remain % (a - b)
    if ret <= mid:
        ok = mid
    else:
        ng = mid


print(ok)

Submission status: Wrong Answer

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

import math
def enough(n):
    rest = [h - B * n * 1.0 for h in H]
    m = sum([ math.ceil(r/(A-B)) for r in rest if r > 0])
    return m <= n

l, r = 1, 10**9

while r - l > 1:
    mid = (l + r) // 2
    if enough(mid):
        r = mid

    else:
        l = mid

    # print(l, r, mid)

print(r)

# print(l)
# for i in range(1, 100):
#     if enough(i):
#         print(i)
#         break

Submission status: Wrong Answer

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

import math
def enough(n):
    rest = [h - B * n * 1.0 for h in H]
    m = sum([ math.ceil(r/(A-B)) for r in rest])
    return m <= n

l, r = 1, 10**9

while r - l > 1:
    mid = (l + r) // 2
    if enough(mid):
        r = mid

    else:
        l = mid

    # print(l, r, mid)

print(r)

# print(l)
# for i in range(1, 100):
#     if enough(i):
#         print(i)
#         break

Submission status: Wrong Answer

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

import math
def enough(n):
    rest = [h - B * n * 1.0 for h in H]
    m = sum([ math.ceil(r/(A-B)) for r in rest])
    return m <= n

l, r = 1, sum([h//A+1 for h in H])

while r - l > 1:
    mid = (l + r) // 2
    if enough(mid):
        r = mid

    else:
        l = mid

    # print(l, r, mid)

print(r)

Submission status: Wrong Answer

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

import math
def enough(n):
    rest = [h - B * n * 1.0 for h in H]
    m = sum([ math.ceil(r/(A-B)) for r in rest])
    return m <= n

l, r = 1, sum(H)//A + 1

while r - l > 1:
    mid = (l + r) // 2
    if enough(mid):
        r = mid

    else:
        l = mid

    # print(l, r, mid)

print(r)

# print(l)
# for i in range(1, 100):
#     if enough(i):
#         print(i)
#         break

Submission status: Wrong Answer

Solution code:
import sys
import heapq

N,A,B = map(int,input().split())
H = []
for _ in range(N):
  h = int(sys.stdin.readline())
  heapq.heappush(H,-h)

maxh = -float('inf')
cnt = 0
dif = A-B
while len(H) > 0:
  h = heapq.heappop(H)
  cnt += 1
  if h+dif >= -(cnt)*B:
    print(cnt+H.count(h))
    exit()
  else:
    heapq.heappush(H,h+dif)

Submission status: Wrong Answer

Solution code:
import math

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


def ok(n):
    d = n * B
    t = 0
    for h in H:
        if h <= d:
            continue
        t += (h - d) / (A - B)
    return t <= n


lo, hi = 0, 10 ** 9

while lo < hi:
    mi = (lo + hi) // 2
    if ok(mi):
        hi = mi
    else:
        lo = mi + 1

print(hi)

Submission status: Wrong Answer

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

h=[]
for i in range(n):
    a=int(input())
    h.append(a)
left=0
right=max(h)+1

def en(t):
    cnt=0
    for i in range(n):
        if h[i]-b*t>0 and (h[i]-b*t)%(a-b)!=0:
            cnt+=(((h[i]-b*t)//(a-b))+1)
        if h[i]-b*t>0 and (h[i]-b*t)%(a-b)==0:
            cnt+=((h[i]-b*t)//(a-b))
    if cnt<=t:
        return  True
    return  False

while left+1<right:
    tmp=(left+right)//2
    if en(tmp):
        right=tmp
    else:
        left=tmp
print(right)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
ans=0
h=[]
for i in range(n):
    a=int(input())
    h.append(a)
left=0
right=10**12
def enough(t):
    for i in range(n):
        h[i]-=b*t
    cnt=0
    for i in range(n):
        if h[i]>0:
            if h[i]%(a-b)!=0:
                cnt+=(h[i]//(a-b))+1
            else:
                cnt+=h[i]//(a-b)
    if cnt<=t:
        return  True
    else:
        return  False

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

ans=right
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil
from bisect import bisect

n, a, b = map(int, input().split())
raw_hs = [int(input()) for _ in range(n)]
hs = sorted(raw_hs, reverse=True)
diff = a - b

c_min = 1
c_max = int(10e9)

while c_max - c_min > 1:
	c = (c_min + c_max) // 2
	tmp_hs = [h - c * b for h in hs]
	rem = sum([ceil(h / diff) for h in tmp_hs])
	if rem > c:
		c_min = c
	else:
		c_max = c

print(c_max)

Submission status: Wrong Answer

Solution code:
from math import ceil
from bisect import bisect

n, a, b = map(int, input().split())
raw_hs = [int(input()) for _ in range(n)]
hs = sorted(raw_hs, reverse=True)
diff = a - b

c_min = 1
c_max = hs[0]

while c_max - c_min > 1:
	c = (c_min + c_max) // 2
	tmp_hs = [h - c * b for h in hs]
	rem = sum([ceil(h / diff) for h in tmp_hs])
	if rem > c:
		c_min = c
	else:
		c_max = c

print(c_max)

Submission status: Wrong Answer

Solution code:
from math import ceil
from bisect import bisect

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

c_min = 1
c_max = hs[0]
c = (c_min + c_max) // 2

while c_max - c_min > 1:
	tmp_hs = [h - c * b for h in hs]
	rem = sum([ceil(h / diff) for h in tmp_hs])
	if rem > c:
		c_min = c
	else:
		c_max = c
	c = (c_min + c_max) // 2

print(c_max)

Submission status: Wrong Answer

Solution code:
from math import ceil
from bisect import bisect

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

c_min = 0
c_max = hs[0]
c = ceil((c_min + c_max) / 2)

while c_max - c_min > 1:
	tmp_hs = [h - c * b for h in hs] 
	cut_hs = tmp_hs[bisect(tmp_hs, 0):]
	rem = sum([ceil(h / diff) for h in cut_hs])
	if rem > c:
		c_min = c
	else:
		c_max = c
	c = ceil((c_min + c_max) / 2)

print(c)

Submission status: Wrong Answer

Solution code:
from math import ceil
from bisect import bisect

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

c_min = 1
c_max = hs[0]
c = ceil((c_min + c_max) / 2)

while True:
	tmp_hs = [h - c * b for h in hs] 
	cut_hs = tmp_hs[bisect(tmp_hs, 0):]
	rem = sum([ceil(h / diff) for h in cut_hs])
	if rem > c:
		c_min = c
	else:
		c_max = c
	c = ceil((c_min + c_max) / 2)

	if c_max - c_min <= 1 :
		break

print(c_max)

Submission status: Wrong Answer

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)
    for i in l1: 
         c+=ceil((i)/(a-b))
    return c<=x
lo=0 
ans=-1 
hi=10**10
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1
    else:
        lo=mi+1 
print(ans)

Submission status: Wrong Answer

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
    r=x 
    for i in l:
        m=ceil(i/b)
        if m<x:
            r=r-(x-m)
    l1=[i-b*x for i in l]
  #  print(l1)
    bc=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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
    for i in l1: 
        c+=ceil((i)/a)
    c+=ceil((b*x)/a)
    return c<=x
lo=0 
ans=-1 
hi=10**19
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1
    else:
        lo=mi+1 
print(ans)

Submission status: Wrong Answer

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)
    for i in l1: 
        c+=ceil((i)/a)
    c+=ceil((b*x)/a)
    return c<=x
lo=0 
ans=-1 
hi=10**13
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1
    else:
        lo=mi+1 
print(ans)

Submission status: Wrong Answer

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)
    for i in l1: 
        c+=ceil((i)/a)
    c+=ceil((b*x)/a)
    return c<=x
lo=0 
ans=-1 
hi=10**19 
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1
    else:
        lo=mi+1 
print(ans)

Submission status: Wrong Answer

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

def C(x):
    Y = [0] * N
    for i in range(N):
        Y[i] = X[i] - x * B
    
    cnt = 0
    for i in range(N):
        if Y[i] - (A - B) >= 0:
            cnt += (Y[i] + A - B - 1) // (A - B)
    return cnt <= x

ng = 0; ok = 10**9
while ok - ng > 1:
    mid = (ng + ok) >> 1
    if C(mid): ok = mid
    else: ng = mid

print(ok)

Submission status: Wrong Answer

Solution code:
def main():
    from math import ceil
    N, A, B = (int(i) for i in input().split())
    h = [int(input()) for i in range(N)]

    def is_ok(h,bomb,N,A,B):
        K = bomb
        cur = 0
        for i in range(N):
            cur += ceil((h[i] - B * K)/(A - B))
        if cur <= K:
            return True
        else:
            return False

    def binary_search_meguru(Arr,N,A,B):
        left = -1
        right = 10**9 + 1
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(Arr,mid,N,A,B): right = mid
            else: left = mid
        return right
    
    print(binary_search_meguru(h,N,A,B))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

def check(T):
    t = 0
    for h in H:
        t += math.ceil((h - B*T)/(A-B))
    return T >= t

def main():
    lb = ub = 0
    for h in H:
        ub += h//B + 1

    while ub - lb > 1:
        mid = (lb + ub)//2
        if check(mid):
            ub = mid
        else:
            lb = mid
            
    print(ub)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
ls = sorted([int(input()) for _ in range(n)])
lo = (ls[-1] + a - 1) // a
hi = (ls[-1] + b - 1) // b + 1
mi = (hi + lo) // 2
while hi > lo + 1:
    mi = (hi + lo) // 2
    if sum([(max(x - mi * b, 0) + a - b - 1) // (a - b) for x in ls]) <= mi:
        hi = mi
    else:
        lo = mi
print(hi if lo == mi else lo)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce



sys.setrecursionlimit(2147483647)
INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, a, b = LI()
L = IR(n)
ok = max(L) // b + 1
ng = 0
while ok > ng + 1:
    mid = (ok + ng) // 2
    remain = mid
    for i in range(n):
        remain -= (L[i] - b * mid) // (a - b) + bool((L[i] - b * mid) % (a - b))
        if remain < 0:
            ng = mid
            break
    else:
        ok = mid



print(ok)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
h = [int(input()) for _ in range(n)]
h.sort(reverse=True)
ans = 0
b_num_max = math.ceil(h[0] / b)



for i in range(1,n):
    b_num_min = math.ceil(h[i] / b)
    a_num = 0
    for j in range(i):
        a_num += math.ceil((h[j] - b_num_min * b) / (a - b))

    if b_num_min <= a_num <= b_num_max:
        print(a_num)
        break
    b_num_max = b_num_min