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:
n,a,b = map(int,input().split())
h_list = []
for _ in range(n):
    h = int(input())
    h_list.append(h)

def ba(s):
    count = 0
    for i in h_list:
        i -= s*b
        count += -(-i//(a-b))
    if count <= s:
        return True
    else:
        return False


ng = 0
ok = 10**9
while ok  > ng +1 :
    mid = (ng+ok)//2
    if ba(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Submission status: Wrong Answer

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

def can_terminate(x):
  count = 0
  for monster in monsters:
    count += max(0, (monster-B*x)//(A-B))
  return count <= x

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
l=[int(input())for i in range(n)]
a-=b
def  enough(x):
    return sum((h-b*x+a-1)//a for h in l)<=x
#(ng,ok]type
ok,ng=10**9,-1
# [ok,ng)type->eraseng,ok=ok,ng
eps=10**(-10)
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if enough(mid):ok=mid
    else:ng=mid
print(ok)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, A, B = map(int, readline().split())
H = list(map(int,read().split()))
H = sorted(H,reverse = True)
t = A-B

def solve(x):
    cnt = 0
    for i in range(N):
        rem = H[i]-x*B
        if rem <= 0:
            break
        else:
            cnt += -(-rem // t)
    if cnt <= x:
        return True
    else:
        return False 
    

left = 1
right = 10**9
while right - left > 1:
    x = (left + right) // 2
    flag = solve(x)
    if flag:
        right = x
    else:
        left = x
        
print(right)

Submission status: Wrong Answer

Solution code:
import bisect
import math

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

R = math.ceil(max(H)/B)
L = 0
ans = R

while True:
    mid = (L + R) // 2
    cnt = 0
    ind = bisect.bisect_left(H,mid * B)
    
    while ind < N:
        cnt += math.ceil((H[ind] - mid*B)/(A-B))
        ind += 1
    if cnt <= mid:
        ans = min(ans,mid)
        if R == mid:
            break
        R = mid
    if cnt > mid:
        if L == mid:
            break
        L = mid
        
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import math

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

R = math.ceil(max(H)/B)
L = 0
ans = R

while True:
    mid = (L + R) // 2
    cnt = 0
    ind = bisect.bisect_right(H,mid * B)
    
    while ind < N:
        cnt += math.ceil((H[ind] - mid*B)/(A-B))
        ind += 1
    if cnt <= mid:
        ans = min(ans,mid)
        if R == mid:
            break
        R = mid
    if cnt > mid:
        if L == mid:
            break
        L = mid
        
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import math

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

R = max(H)//B + 1
L = 0
ans = R

while True:
    mid = (L + R) // 2
    cnt = 0
    ind = bisect.bisect_right(H,mid * B)
    
    while ind < N:
        cnt += math.ceil((H[ind] - mid*B)/(A-B))
        ind += 1
    if cnt <= mid:
        ans = min(ans,mid)
        if R == mid:
            break
        R = mid
    if cnt > mid:
        if L == mid:
            break
        L = mid
        
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import math

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

R = max(H)//B
L = min(H)//A-1
ans = R

while True:
    mid = (L + R) // 2
    cnt = 0
    ind = bisect.bisect_right(H,mid * B)
    
    while ind < N:
        cnt += math.ceil((H[ind] - mid*B)/(A-B))
        ind += 1
    if cnt <= mid:
        ans = min(ans,mid)
        if R == mid:
            break
        R = mid
    if cnt > mid:
        if L == mid:
            break
        L = mid
        
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import math

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

R = max(H)//B + 1
L = min(H)//A - 1
ans = R

while True:
    mid = (L + R) // 2
    cnt = 0
    ind = bisect.bisect_right(H,mid * B)
    while ind < N:
        cnt += math.ceil((H[ind] - mid*B)/(A-B))
        ind += 1
    if cnt <= mid:
        ans = min(ans,mid)
        if R == mid:
            break
        R = mid
    if cnt > mid:
        if L == mid:
            break
        L = mid
        
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import math

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

R = max(H)//B + 1
L = min(H)//A - 1
ans = R

while True:
    mid = (L + R) // 2
    cnt = 0
    ind = bisect.bisect_right(H,mid * B)
    while ind < N:
        cnt += math.ceil((H[ind] - mid*B)/(A-B))
        ind += 1
        if cnt > mid:
            break
    if cnt <= mid:
        ans = min(ans,mid)
        if R == mid:
            break
        R = mid
    if cnt > mid:
        if L == mid:
            break
        L = mid
        
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import math

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

R = max(H)//B + 1
L = min(H)//A
ans = R

while True:
    mid = (L + R) // 2
    cnt = 0
    ind = bisect.bisect_right(H,mid * B)
    while ind < N:
        cnt += math.ceil((H[ind] - mid*B)/(A-B))
        ind += 1
        if cnt > mid:
            break
    if cnt <= mid:
        ans = min(ans,mid)
        if R == mid:
            break
        R = mid
    if cnt > mid:
        if L == mid:
            break
        L = mid
        
print(ans)

Submission status: Wrong Answer

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


ok, ng = 10**9+1, 0
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    ok_flag = True
    cnt = 0
    for h in hl:
        rem = h - mid*b
        need = (rem-1)//(a-b) + 1
        cnt += need
    # ...
    if cnt <= mid:
        ok = mid
    else:
    	ng = mid
print(ok)

Submission status: Wrong Answer

Solution code:
def widespread(n, a, b, summ):
	if b < n:
		ans = summ // (a+b)
	else:
		ans = summ // a
	if a < n:
		ans = ans // (n // a)
	return ans

n, a, b = map(int, input().split())
summ = 0
for _ in range(n):
	h = int(input())
	summ += h
print(widespread(n, a, b, summ))

Submission status: Wrong Answer

Solution code:
import sys
from heapq import heapify, heappop, heappush
from collections import defaultdict

def main():
    finput=lambda :sys.stdin.readline().strip()
    n,a,b=map(int,finput().split())
    h=[int(finput()) for _ in range(n)]
    gs=lambda a,b:a//b+(a%b>0)
    def enough(t):
        s=sum([max(x-t*b,0)//(a-b)+(max(x-t*b,0)%b>0) for x in h])
        if s<=t:
            return True
        else:
            return False
    #def biser(t,l):
    #    if l==0:
    #        return t
    #    t=t+l//2
    #    if enough(t):
    #        return biser(t-l//2,l//2)
    #    else:
    #        return biser(t+1,l-l//2)
    l=max(h)//b+1
    t=0
    while l>0:
        t=t+l//2
        if enough(t):
            t=t-l//2
            l=l//2
        else:
            t+=1
            l=l-l//2
    print(t)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys,math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

def is_ok(arg):
    chk = 0
    for i in h:
      p = (-arg*b+i)//(a-b)
      if p != (-arg*b+i)/(a-b):
        p += 1
      chk += p
    return chk <= arg


def bisect_ok(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義
    ng = 最小の値-1 ok = 最大の値+1 で最小
    最大最小が逆の場合はng ok をひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

print(bisect_ok(0,10**9))

Submission status: Wrong Answer

Solution code:
import sys,math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

def is_ok(arg):
    chk = 0
    for i in h:
      chk += math.ceil((-arg*b+i)/(a-b))
    return chk <= arg


def bisect_ok(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義
    ng = 最小の値-1 ok = 最大の値+1 で最小
    最大最小が逆の場合はng ok をひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

print(bisect_ok(0,10**9))

Submission status: Wrong Answer

Solution code:
import math

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

def C(T):
    t = 0
    for i in range(N):
        t += math.ceil((h[i]-B*T)/(A-B))
    if t <= T:
        return True
    else:
        False
l, r = 0, 10**32
while r - l > 1:
    mid = (l+r) // 2
    if C(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)]

def C(T):
    t = 0
    for i in range(N):
        t += math.ceil((h[i]-B*T)/(A-B))
    if t <= T:
        return True
    else:
        False
l, r = 0, 10**18
while r - l > 1:
    mid = (l+r) // 2
    if C(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)]

def C(T):
    t = 0
    for i in range(N):
        t += math.ceil((h[i]-B*T)/(A-B))
    if t <= T:
        return True
    else:
        False
l, r = 0, 10**9
while r - l > 1:
    mid = (l+r) // 2
    if C(mid):
        r = mid
    else:
        l = mid


print(r)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
s = 0
H = []
for _ in range(n):
    h = int(input())
    H.append(h)
from copy import deepcopy

from math import ceil
def count(x):
    Hc = deepcopy(H)
    cnt = 0
    for i in range(n):
        Hc[i] -= b*x
        if Hc[i]>0:
            cnt += ceil((Hc[i]//(a-b)))
    return cnt <= x

l,r = 0, max(H)//b + 1
while l < r:
    mid = (l+r)//2
    if count(mid):
        r = mid
    else:
        l = mid+1
print(r)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
s = 0
H = []
for _ in range(n):
    h = int(input())
    H.append(h)
from copy import deepcopy

from math import ceil
def count(x):
    Hc = deepcopy(H)
    cnt = 0
    for i in range(n):
        Hc[i] -= b*x
        if Hc[i]>0:
            cnt += (Hc[i]//(a-b)) + 1
    return cnt <= x

l,r = 0, max(H)//b + 1
while l < r:
    mid = (l+r)//2
    if count(mid):
        r = mid
    else:
        l = mid+1
print(r)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
s = 0
H = []
for _ in range(n):
    h = int(input())
    H.append(h)
from copy import deepcopy

from math import ceil
def count(x):
    Hc = deepcopy(H)
    cnt = 0
    for i in range(n):
        Hc[i] -= b*x
        cnt += ceil(Hc[i]/(a-b))
    return cnt <= x

l,r = 0, max(H)//b + 1
while l < r:
    mid = (l+r)//2
    if count(mid):
        r = mid
    else:
        l = mid+1
print(r)

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
from operator import mul

INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 組合せnCr
def combinations_count(n, r):
    if n < r:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]



# ここから書き始める
def is_ok(key, h, a, b, n):
    total = 0
    for i in range(n):
        total += -(-(h[i] - b * key) // (-b + a))
    if total <= key:
        return True
    return False

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

x = -(-max(h) // b)
ng = 0
ok = x + 1

while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(mid, h, a, b, n):
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Wrong Answer

Solution code:
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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

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

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

    
resolve()

Submission status: Wrong Answer

Solution code:
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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

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

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

    
resolve()

Submission status: Wrong Answer

Solution code:
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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

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

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

    
resolve()

Submission status: Wrong Answer

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

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

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

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

    
resolve()

Submission status: Wrong Answer

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

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

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

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

    
resolve()

Submission status: Wrong Answer

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

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

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

            


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

    
resolve()

Submission status: Wrong Answer

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

def ceil(x,y):
    return -((-x)//y)
#print(ceil(5,2))
n,a,b=MI()
hp=[I() for i in range(n)]
x=0
y=10**9+1
while x+1<y:
    mid=(x+y)//2
    count=0
    for i in range(n):
        count+=ceil(hp[i]-b*mid,a-b)
    #print(mid,end=" ")
    #print(count<=mid)
    if count<=mid:
        y=mid
    else:
        x=mid
print(y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

def ceil(x,y):
    return -((-x)//y)
n,a,b=MI()
hp=[I() for i in range(n)]
x=0
y=10**9+1
while x+1<y:
    mid=(x+y)//2
    count=0
    for i in range(n):
        count+=ceil(hp[i]-b*mid,a-b)
    if count<=mid:
        y=mid
    else:
        x=mid
print(mid)

Submission status: Wrong Answer

Solution code:
from math import ceil

def is_ok(m):

    tmp = h[:]

    for i in range(N):
        tmp[i] -= m*B
    
    if not any(tmp):
        return False
    
    rem = 0
    for i in tmp:
        if i > 0:
            rem += ceil(i/(A-B))

    if rem > m:
        return False

    return True

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

r = 10**10
l = 0

while abs(l-r) > 1:

    m = (r+l)//2

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

print(r)

Submission status: Wrong Answer

Solution code:
import numpy as np

def is_ok(m):
    tmp = h - B*m

    if not any(tmp):
        return False
    
    rem = sum([np.ceil(i/(A-B)) for i in tmp])

    if rem > m:
        return False

    return True

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

r = 10**10
l = 0

while abs(l-r) > 1:

    m = (r+l)//2

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

print(r)

Submission status: Wrong Answer

Solution code:
import sys
def waru(n,t):
  if n%t==0:
    return n//t
  else:
    return (n//t)+1
def main():
  input = sys.stdin.readline
  s=0
  L=list()
  N,A,B=map(int,input().split())
  for i in range(N):
    h=int(input())
    L.append(h)
  c=sum(L)//(A+B*(N-1))
  t=max(L)//B
  for i in range(c,t+1):
    R=[j-i*B for j in L if j-(i*B)>0]
    R=[waru(i,A-B) for i in R]
    if sum(R)<=i:
      print(i)
      sys.exit()
main()

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

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

    l = k[0] // b
    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()