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 main():
    from math import ceil
    n, a, b, *k = map(int, open(0).read().split())
    k.sort()

    l = k[0] // a
    r = k[-1] // b
    m = (l + r) // 2
    while l + 1 < r:
        c = sum(ceil((i - m * b) / (a - b)) if i - m * b > 0 else 0 for i in k)
        if c <= m:
            r = m
        else:
            l = m

        m = (l + r) // 2

    print(r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import ceil
n,a,b = map(int,input().split())
h = [int(input()) for _ in range(n)]
l = 0
r = 10**18

def f(x):
    res = 0
    for i in range(n): res += ceil((h[i]-b*x)/(a-b))
    return res <= x

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

Submission status: Wrong Answer

Solution code:
import math
def binsearch(l, r, fn):
    while r - l > 1:
        m = (l + r) // 2
        if fn(m):
            l = m
        else:
            r = m
    return l

def main():
    N, A, B = map(int, input().split())
    l = []
    C = A - B
    for _ in range(N):
        h = int(input())
        l.append(h)
    def func(i):
        if max(l) <= B*i:
            return False
        r = 0
        for j in l:
            r += math.ceil((j - B*i) / C)
        if r <= i:
            return False
        return True
    return 1 + binsearch(0, 1000000000, func)

print(main())

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
h=[int(input()) for _ in range(n)]
def bisearch(k):# k回で倒せるかどうか
  ret=0
  for hi in h:
    ret+=(hi-b*k+a-b-1)//(a-b)
  return ret<=k
l,r=0,pow(10,9)
while r-l>1:
  x=(l+r+1)//2
  if bisearch(x):
    r=x
  else:
    l=x
while bisearch(r):
  r-=1
print(r+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
h=[int(input()) for _ in range(n)]
def bisearch(k):# k回で倒せるかどうか
  ret=0
  for hi in h:
    ret+=(hi-b*k+a-b-1)//(a-b)
  return ret<=k
l,r=0,pow(10,9)
while r-l>1:
  x=(l+r+1)//2
  if bisearch(x):
    r=x
  else:
    l=x

print(r)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

hi = 10**10
low = -1

def calc(x):
    y = h-x*b
    y[x<0] = 0
    f = np.ceil(y/(a-b)).sum()
    return f

while hi-low > 1:
    ave = (hi+low)//2
    if calc(ave) <= ave:
        hi = ave
    else:
        low = ave
    
print(hi)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

hi = 10**10
low = -1

def calc(x):
    y = h-x*b
    y[x<0] = 0
    f = np.ceil(y/(a-b)).sum()
    return f

while hi-low > 1:
    ave = (hi+low)//2
    if calc(ave) > ave:
        low = ave
    else:
        hi = ave
    
print(hi)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

hi = 10**10
low = -1

def calc(x):
    f = np.ceil(((h-b*x)/(a-b))).sum()
    return f

while hi-low > 1:
    ave = (hi+low)//2
    if calc(ave) > ave:
        low = ave
    else:
        hi = ave
    
print(hi)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

hi = 10**10
low = -1

def calc(x):
    f = np.ceil(((h-b*x)/(a-b))).sum()
    return f

while hi-low > 1:
    ave = (hi+low)//2
    if calc(ave) <= ave:
        hi = ave
    else:
        low = ave
    
print(hi)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

hi = 10**10
low = -1

def calc(x):
    f = ((h-b*x)//(a-b)).sum()
    return f

while hi-low > 1:
    ave = (hi+low)//2
    if calc(ave) > ave:
        low = ave
    else:
        hi = ave
    
print(hi)

Submission status: Wrong Answer

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


def isOk(k):
    return k >= 0


ok, ng = max(h)//B+1, 1
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    c = mid
    for i in range(N):
        t = h[i]-mid*B
        if t > 0:
            c -= (t+A-B-1)//(A-B)
            if c < 0:
                break
    if isOk(c):
        ok = mid
    else:
        ng = mid

print(ok)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,a,b = map(int, input().split())
hs = [None]*n
for i in range(n):
    hs[i] = int(input())
    
def sub(x):
    vs = [item - b*x for item in hs]
    return sum(v // (a-b) + bool(v % (a-b)) for v in vs) <= x

l = 0
r = 10**9

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

Submission status: Wrong Answer

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

def main():
    n,a,b = map(int,input().split())
    h = [int(input()) for _ in range(n)]
    ok = max(h)
    ng = 0
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        cnt = 0
        for i in range(n):
            cnt += max(0, math.ceil((h[i]-mid*b)/a))
        if cnt <= mid:
            ok = mid
        else:
            ng = mid
    print(ok)

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)]
ng = 0
ok = 10 ** 9
while ok - ng > 1:
  mid = (ok + ng) // 2
  s = 0
  for i in h:
    s += (i - mid * b + a - b - 1) // (a - b)
  if s <= mid:
    ok = mid
  else:
    ng = mid
print(ok)

Submission status: Wrong Answer

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

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

#二分探索用のコード

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

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

#二分探索用のコード

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

print(l)

Submission status: Wrong Answer

Solution code:
import math


def check(k, A, B, H):
    return sum([max([0, math.ceil((h - B * k) // (A - B))]) for h in H]) <= k


def main():
    N, A, B = list(map(int, input().split(' ')))
    H = [int(input()) for _ in range(N)]
    ng, ok = 0, 10**9
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if check(mid, A, B, H):
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math


def check(k, A, B, H):
    return sum([math.ceil((h - B * k) / (A - B)) for h in H]) <= k


def main():
    N, A, B = list(map(int, input().split(' ')))
    H = [int(input()) for _ in range(N)]
    ng, ok = 0, 10**9
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if check(mid, A, B, H):
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import ceil

def check(k):
    if ((N-1)*B+A)*k < s:
        return False
    return True

N,A,B = map(int,input().split())
h = [int(input()) for _ in range(N)]
m = max(h)
s = sum(h)
tmp = 0
if h.count(m) == N:
    tmp = 1

left = -1
right = 1e15

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

print(int(right)+tmp)

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B = LI()
    h = [NI() for _ in range(N)]

    h.sort()
    sa = []
    for x in h:
        tmp = round((x - h[0]) / (A-B))
        sa.append(tmp)
    ans = sum(sa)
    for i in range(N):
        h[i] -= (A-B) * sa[i] + B * ans
    a = math.ceil(max(h)/(A + B*(N-1)))
    ans += a * N
    for i in range(N):
        h[i] -= a * (A + B*(N-1))
    max_h = -min(h)
    min_h = -max(h)
    if max_h >= A:
        ans -= min(min_h//B,(max_h - (A-B))//B)
    print (ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B = LI()
    h = [NI() for _ in range(N)]

    h.sort()
    sa = []
    for x in h:
        tmp = math.ceil((x - h[0]) / (A-B))
        sa.append(tmp)
    ans = sum(sa)
    for i in range(N):
        h[i] -= (A-B) * sa[i] + B * ans
    a = round((h[0])/(A + B*(N-1)))
    ans += a * N
    for i in range(N):
        h[i] -= a * (A + B*(N-1))
    max_h = -min(h)
    min_h = -max(h)
    if max_h >= A:
        ans -= min(min_h//B,(max_h - (A-B))//B)
    print (ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B = LI()
    h = [NI() for _ in range(N)]

    if N == 1:
        print(math.ceil(h[0]/A))
        exit(0)
    h.sort()
    sa = []
    for x in h:
        tmp = math.ceil((x - h[0]) / (A-B))
        sa.append(tmp)
    ans = sum(sa)
    for i in range(N):
        h[i] -= (A-B) * sa[i] + B * ans
    a = math.ceil((h[0])/(A + B*(N-1)))
    ans += a * N
    for i in range(N):
        h[i] -= a * (A + B*(N-1))
    max_h = -min(h)
    min_h = -max(h)
    if max_h >= A:
        ans -= min(min_h//B,(max_h - (A-B))//B)
    print (ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B = LI()
    h = [NI() for _ in range(N)]

    h.sort()
    sa = []
    for x in h:
        tmp = math.ceil((x - h[0]) / (A-B))
        sa.append(tmp)
    ans = sum(sa)
    for i in range(N):
        h[i] -= (A-B) * sa[i] + B * ans
    a = math.ceil((h[0])/(A + B*(N-1)))
    ans += a * N
    for i in range(N):
        h[i] -= a * (A + B*(N-1))
    max_h = -min(h)
    min_h = -max(h)
    if max_h >= A:
        ans -= min(min_h//B,(max_h - (A-B))//B)
    print (ans)

if __name__ == '__main__':
    main()

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 binary_search(x):
    H_tmp = H - B * x
    H_tmp = H_tmp[H_tmp > 0]
    count = ((H_tmp + A - B - 1) // (A - B)).sum()
    return x >= count

left = 0
right = 10**10

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

print(mid)

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 binary_search(x):
    H_tmp = H - B * x
    H_tmp = H_tmp[H_tmp > 0]
    count = ((H_tmp + A - B - 1) // (A - B)).sum()
    return x >= count

left = 0
right = 10**18

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

print(mid)

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 binary_search(x):
    H_tmp = H - B * x
    H_tmp_d = H_tmp[H_tmp > 0] // (A-B) + 1
    H_tmp_r = H_tmp[H_tmp > 0] % (A-B)
    count = H_tmp_d.sum() - H_tmp_r[H_tmp_r == 0].sum()
    return x >= count

left = 0
right = 10**10

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

print(mid)

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 binary_search(x):
    H_tmp = H - B * x
    H_tmp_d = H_tmp[H_tmp >= 0] // (A-B) + 1
    H_tmp_r = H_tmp[H_tmp >= 0] % (A-B)
    count = H_tmp_d.sum() - H_tmp_r[H_tmp_r == 0].sum()
    return x >= count

left = 0
right = 10**18

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

print(mid)

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 binary_search(x):
    H_tmp = H - B * x
    H_tmp_d = H_tmp[H_tmp > 0] // (A-B) + 1
    H_tmp_r = H_tmp[H_tmp > 0] % (A-B)
    count = H_tmp_d.sum() - H_tmp_r[H_tmp_r == 0].sum()
    return x >= count

left = 0
right = 10**18

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

print(mid)

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 binary_search(x):
    H_tmp = H - B * x
    count = (H_tmp[H_tmp > 0] // (A-B) + 1).sum()
    return x >= count

left = 0
right = 10**20

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

print(mid)

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 binary_search(x):
    H_tmp = H - B * x
    count = (H_tmp[H_tmp > 0] // (A-B) + 1).sum()
    return x >= count

left = 0
right = 10**9

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

print(mid)

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 binary_search(x):
    H_tmp = H - B * x
    count = (H_tmp[H_tmp > 0] // (A-B) + 1).sum()
    return x >= count

left = 0
right = 10**30

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

print(mid)

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 binary_search(x):
    H_tmp = H - B * x
    count = (H_tmp[H_tmp > 0] // (A-B) + 1).sum()
    return x >= count

left = 0
right = 10**18

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

print(mid)

Submission status: Wrong Answer

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

ok = maxim_h // a * n
ng = 0
while abs(ok - ng) > 1:

    X = (ok + ng) // 2
    #X回爆発を起こす必要があると仮定する

    cnt = 0
    flag = 1
    for val in h:
        if val <= b * X:continue
        temp = (val - b * X + a - b - 1) // (a - b)
        cnt += temp

        if cnt > X:
            flag = 0
            break

    #print(X, cnt, ok)
    if flag:ok = X
    else:ng = X
print(ok)

Submission status: Wrong Answer

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

ok = sum_h // a
ng = 0
while abs(ok - ng) > 1:

    X = (ok + ng) // 2
    #X回爆発を起こす必要があると仮定する

    cnt = 0
    flag = 1
    for val in h:
        if val <= b * X:continue
        temp = (val - b * X + a - b - 1) // (a - b)
        cnt += temp

        if cnt > X:
            flag = 0
            break

    #print(X, cnt, ok)
    if flag:ok = X
    else:ng = X
print(ok)

Submission status: Wrong Answer

Solution code:
n,a,b= map(int,input().split())
sh = sorted([int(input()) for i in range(n)])
sumh = sum(sh)
def nibu(t):
    rt=0
    for i in range(n):
        temp = -1*(-1*max(0,sh[i]-t*b)//(a-b))
        if temp>0:rt+=-1*(-1*max(0,sh[i]-t*b)//(a-b))
        else:break
    return True if t>=rt else False
l,r=0,-1*(-1*sumh//b)
while r-l!=1:
    m = (l+r)//2
    if nibu(m):r=m
    else:l=m
print(r)

Submission status: Wrong Answer

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

ub = 10 ** 15
lb = 0
while ub - lb > 1:
    mid = (ub + lb) // 2
    cnt = 0
    for i in range(N):
        cnt += -(-(X[i] - B * mid) // (A - B))

    if cnt > mid:
        lb = mid
    else:
        ub = mid

print(ub)

Submission status: Wrong Answer

Solution code:
def judge(x):
    count = 0
    for hi in h:
        count += (hi - b*x + c-1)//c 
    if count<=x:
        return True
    else:
        return False

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

c= a-b

ng = 0
ok = 10**9

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

Submission status: Wrong Answer

Solution code:
def f(x,hp):
  hp=[hh-(b*x) for hh in hp]
  c=0
  for p in hp:
    if p<=0:continue
    c+=(p+(a-b)-1)/(a-b)
  return c<=x

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]
import sys
m=max(h)
for i in range((m//a),(m//b)+1):
    cnt=0
    dif=a-b
    for k in h:
        if (k-(b*i))>0:
            if ((k-(b*i))%dif)==0:
                cnt+=((k-(b*i))//dif)
            else:
                cnt+=((k-(b*i))//dif)+1
            # print(i)
            # print(cnt)
        else:
            pass
    if cnt<=i:
        print(i)
        sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
H = list(int(input()) for _ in range(n))
l,r = 0, 10**9
d = a-b
while r-l>1:
    mid = (r+l)//2
    tmp = 0
    for h in H:
        if h <= mid*b:
            continue
        tmp += math.ceil((h-mid*b)/d)
    if tmp < mid:
        r = mid
    else:
        l = mid
print(l)

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
H = list(int(input()) for _ in range(n))
l,r = 0, 10**9
d = a-b
while r-l>1:
    mid = (r+l)//2
    tmp = 0
    for h in H:
        if h <= mid*b:
            continue
        tmp += math.ceil((h-mid)/d)
    if tmp < mid:
        r = mid
    else:
        l = mid
print(l)

Submission status: Wrong Answer

Solution code:
import math
class Range_BIT:
    def __init__(self, n):
        self.n = n
        self.bit0 = [0]*(n+1)
        self.bit1 = [0]*(n+1)
    
    def _Add(self, k, x, is_bit0=True):
        if is_bit0 == True:
            data = self.bit0
        else:
            data = self.bit1
        while k <= self.n:
            data[k] += x
            k += k & -k
    
    def _Get(self, data, k):
        s = 0
        while k:
            s += data[k]
            k -= k&-k
        return s
    
    """ 配列の獲得 """
    def Array(self):
        array = [0]*(n+1)
        for i in range(self.n):
            array[i] = self.Get(i+1,i+2)
        return array[:-1]
    
    """ 区間[l:r)に対してxを加算 """
    def Add(self, l, r, x):
        self._Add(l, -x*(l-1), is_bit0=True)
        self._Add(r, x*(r-1), is_bit0=True)
        self._Add(l, x, is_bit0=False)
        self._Add(r, -x, is_bit0=False)
    
    """ 区間[l:r)の総和 """
    def Get(self, l, r):
        Pi = self._Get(self.bit1, r-1)*(r-1) - self._Get(self.bit1, l-1)*(l-1)
        Qi = self._Get(self.bit0, r-1) - self._Get(self.bit0, l-1)
        return Pi+Qi

n,a,b = map(int,input().split())
d = a-b
rbit = Range_BIT(n)
for i in range(n):
    h = int(input())
    rbit.Add(i+1, i+2, h)
ans = 0
while True:
  arr = rbit.Array()
  mx = max(arr)
  idx = arr.index(mx)
  if mx <= 0:
    break
  tmp = math.ceil(mx/a)
  rbit.Add(1,n+1,-b*tmp)
  rbit.Add(idx+1, idx+2, -d*tmp)
  ans += tmp
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_right


def solve(t):
    global A, B, C
    k = bisect_right(H, B * t)
    cnt = 0
    for i in range(k, N):
        h = H[i]
        h -= B * t
        cnt += (h + C - 1) // C
    return cnt <= t


N, A, B = map(int, input().split())
C = A - B
H = [int(s) for s in sys.stdin.readlines()]

H.sort()

# [ok, ng) - Maximum
# (ng, ok] - Minimum
# ok が 最終的な答え
ng = 1
ok = 10 ** 9 + 1000
k = 0
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok)

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

low,high=0,10**9+1
while high-low>1:
    mid=(high+low)//2
    cnt=0
    for i in range(n):
        tmp=h[i]-mid*b
        cnt+=math.ceil(tmp/(a-b))
    if cnt>mid:
        low=mid
    else:
        high=mid
    # print(high,low)
print(high)

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

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

import math

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

while abs(right-left) > 1:
    center = (right+left)//2
    
    if check(center) == True:
        right = center
    elif check(center) == False:
        left = center
        
print(center)

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

ans = []

for i in range(N):
    count = h[i]//B
    res = h[i] - B*count
    if res <= (A-B)*count:
        ans.append(count)
    else:
        ans.append(count+res//A+1)
        
print(max(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())

res = max(h) - max(h) // B * B
if res <= max(h) // B  * (A-B):
    print(max(h) // B)
else:
    print(max(h) // B + res // (A-B))

Submission status: Wrong Answer

Solution code:
def isok(arg):
    count = arg
    for i in range(n):
        count -= -(-(h[i]-b*arg)//(a-b))
    if count >= 0:
        return True
    else:
        return False

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

n,a,b = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
print(bisect(0,10**9))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

d = sum(c)
e = a - b
ans = 0
while d > 0:
    d = d-e - b * n
    ans += 1
print(ans)

Submission status: Wrong Answer

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

d = sum(c)
ans = 0
while d > 0:
    d = (d-a) - b * (n-1)
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
c = a - b
h = []
maxValue = 0
#minValue = 1000000000
for i in range(n):
  temp = int(input())
  h.append(temp)
  maxValue = max(maxValue, temp)
  #minValue = min(minValue, temp)
sum = sum(h)
#for i in range(int(sum/(c+n*b)), int(maxValue/b)+1):
#for i in range(int(maxValue/b), 0, -1):
for i in range(int(sum/(b*n)), 0, -1):
  cnt = 0
  for m in range(n):
    if h[m] - i*b > 0:
      cnt += math.ceil((h[m]-i*b)/c)
  if cnt > i:
    print(i + 1)
    exit()

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
c = a - b
h = []
maxValue = 0
#minValue = 1000000000
for i in range(n):
  temp = int(input())
  h.append(temp)
  maxValue = max(maxValue, temp)
  #minValue = min(minValue, temp)
sum = sum(h)
#for i in range(int(sum/(c+n*b)), int(maxValue/b)+1):
#for i in range(int(maxValue/b), 0, -1):
for i in range(int(sum/(c+b*n)), 0, -1):
  cnt = 0
  for m in range(n):
    if h[m] - i*b > 0:
      cnt += math.ceil((h[m]-i*b)/c)
  if cnt > i:
    print(i + 1)
    exit()

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
c = a - b
h = []
maxValue = 0
#minValue = 1000000000
for i in range(n):
  temp = int(input())
  h.append(temp)
  maxValue = max(maxValue, temp)
  #minValue = min(minValue, temp)
sum = sum(h)
for i in range(int(sum/(a+n*b)), int(maxValue/b)+1):
  cnt = 0
  for m in range(n):
    if h[m] - i*b > 0:
      cnt += math.ceil((h[m]-i*b)/c)
  if cnt <= i:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
c = a - b
h = []
maxValue = 0
#minValue = 1000000000
for i in range(n):
  temp = int(input())
  h.append(temp)
  maxValue = max(maxValue, temp)
  #minValue = min(minValue, temp)
sum = sum(h)
for i in range(int(sum/(n*b))-1, int(maxValue/b)+1):
  cnt = 0
  for m in range(n):
    if h[m] - i*b > 0:
      cnt += math.ceil((h[m]-i*b)/c)
  if cnt <= i:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
c = a - b
h = []
maxValue = 0
#minValue = 1000000000
for i in range(n):
  temp = int(input())
  h.append(temp)
  maxValue = max(maxValue, temp)
  #minValue = min(minValue, temp)
sum = sum(h)
for i in range(int(sum/(c+n*b)), int(maxValue/b)+1):
  cnt = 0
  for m in range(n):
    if h[m] - i*b > 0:
      cnt += math.ceil((h[m]-i*b)/c)
  if cnt <= i:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
c = a - b
h = []
maxValue = 0
minValue = 1000000000
for i in range(n):
  temp = int(input())
  h.append(temp)
  maxValue = max(maxValue, temp)
  minValue = min(minValue, temp)
for i in range(int(minValue/b), int(maxValue/b)+1):
  cnt = 0
  for m in range(n):
    if h[m] - i*b > 0:
      cnt += (h[m]-i*b)/c
  if cnt <= i:
    print(i)
    exit()

Submission status: Wrong Answer

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

h = []

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

def det(num):
    count = 0
    for i in range(N):
        H = h[i]-B*num
        count += H//(A-B) + min(1,H%(A-B))
    if count <= num:
        return True
    else:
        return False

x = 1###False
y = max(h)###True

while y - x > 1:
    if det((x+y)//2):
        y = (x+y)//2
    else:
        x = (x+y)//2
    #print(x,y)

print(y)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
H = []
Count = []
List = []
for i in range(N):
  H.append(int(input()))
for k in range(max(H)//A+N):
  H.append(max(H)+B-A)
  H.remove(max(H))
  for j in range(len(H)):
    List.append(H[j]-B)
  Count.append(1)
  H = List
  List = []
  print(max(H))
  if max(H)<=0:
    break
print(sum(Count))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
INF = 10**20
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
import numpy as np

def main():
    n,a,b = map(int,input().split())
    H = np.array([int(input()) for _ in range(n)])

    a -= b
    def ok(x): #x回の爆発で倒せるか
        return sum((H - b * x + a - 1)//a) <=  x
    
    l = -1
    r = 10 ** 12
    while r - l > 1:
        mid = (r + l)//2
        if ok(mid):
            r = mid
        else:
            l = mid  
    print(r)

if __name__=='__main__':
    main()

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+2<r:
    m=(r-l)//2+l
    t=m*B
    c=0
    for i in h:
        if i>t:
            c+=-((-i+t)//k)
        else:
            break
    if c>m:
        l=m
    else:
        r=m+1
print(r-1)