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:
from math import ceil

N,A,B = map(int, input().split())
H = []
for i in range(N):
    H.append(int(input()))
    
H.sort(reverse=True)

# T回の攻撃で全員倒せるかを判定する関数
def enough(T:int) -> bool:
    normal = B*T   # 通常攻撃でのダメージ
    addit = A-B    # 追加攻撃でのダメージ
    
    cnt = 0        # 追加攻撃の必要回数
    for h in H:
        need_add = ceil((h-normal) / addit)
        cnt += need_add
        
    return cnt <= T

# enough(T) == True となる最小のTを探す
# lowの更新で終わればhighが答え、highの更新で終わってもhighが答え
def search() -> int:
    low = 0             # 絶対False
    high = 10**9 + 1    # 絶対True
    
    # midがhighでもlowでもない数になるようにする
    while high - low > 1:
        mid = (high + low) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
            
    return high

print(search())

Submission status: Wrong Answer

Solution code:
from math import ceil

N,A,B = map(int, input().split())
H = []
for i in range(N):
    H.append(int(input()))
    
H.sort(reverse=True)

# T回の攻撃で全員倒せるかを判定する関数
def enough(T:int) -> bool:
    normal = B*T   # 通常攻撃でのダメージ
    addit = A-B    # 追加攻撃でのダメージ
    
    cnt = 0        # 追加攻撃の必要回数
    for h in H:
        need_add = ceil((h-normal) // addit)
        cnt += need_add
        
    return cnt <= T

# enough(T) == True となる最小のTを探す
# lowの更新で終わればhighが答え、highの更新で終わってもhighが答え
def search() -> int:
    low = 0             # 絶対False
    high = 10**9 + 1    # 絶対True
    
    # midがhighでもlowでもない数になるようにする
    while high - low > 1:
        mid = (high + low) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
            
    return high

print(search())

Submission status: Wrong Answer

Solution code:
import math

def solve():
    n, a, b = list(map(int, input().split()))
    h = [int(input()) for _ in range(n)]
    h = sorted(h)

    def is_enough(t):
        t_check = 0
        for hh in h:
            if hh > 0:
                t_check += int(math.ceil((hh-b*t)/(a-b)))
        if t_check > t: return False
        else: return True

    t_min = 1
    t_max = h[-1]//b+1 # number of spell
    while t_min != t_max-1:
        t_next = (t_min+t_max)//2
        if is_enough(t_next):
            t_max = t_next
        else:
            t_min = t_next
        # print(t_min, t_max)

    if is_enough(t_min): print(t_min)
    else: print(t_max)
    return

solve()

Submission status: Wrong Answer

Solution code:

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(N, A, B, H):
    H.sort(reverse=True)

    def e(t):
        b = B*t
        a = A-B
        for h in H:
            h -= b
            if b > 0:
                t -= int(math.ceil(h/a))
        return t >= 0

    l = 0
    r = max(H)
    while r - l > 1:
        m = (r+l)//2
        if e(m):
            r = m
        else:
            l = m

    return r


def main():
    N, A, B = read_int_n()
    H = [read_int() for _ in range(N)]

    print(slv(N, A, B, H))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Prim(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = list(set(V))

    used = set([])
    q = []
    heapq.heappush(q, (0, V[0]))

    ret = 0
    while q:
        c, v = heapq.heappop(q)

        if v in used:
            continue
        used.add(v)
        ret += c
        for u in g[v]:
            heapq.heappush(q, (g[v][u], u))
    return ret


@mt
def slv(N, A, B, H):
    H.sort(reverse=True)

    def e(t):
        b = B*t
        a = A-B
        for h in H:
            h -= b
            if b > 0:
                t -= math.ceil(h/a)
        return t >= 0

    l = 0
    r = max(H)
    while r - l > 1:
        m = (r+l)//2
        if e(m):
            r = m
        else:
            l = m

    return r


def main():
    N, A, B = read_int_n()
    H = [read_int() for _ in range(N)]

    print(slv(N, A, B, H))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()

def f():
    p0, p1 = ' ', s[0]
    for i, p2 in enumerate(s[1:] + '_'):
        if p1 == p2:
            print(i + 1, i + 2)
            return
        if p0 == p2:
            print(i, i + 2)
            return
        p0, p1 = p1, p2
    print(-1, -1)
    return
f()

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil, floor
n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]

def enough(t):
    cnt = 0
    for h in H:
        # 全体攻撃を受けた残りHP
        rh = h - b * t
        if rh <= 0:
            continue
        cnt += rh//(a-b)
        if rh%(a-b) != 0:
            cnt += 1
    if cnt <= t:
        return True
    else:
        return False

bot = floor(sum(H)/(a+(n-1)*(a-b)))
if enough(bot):
    print(bot)
    sys.exit(0)
top = ceil(max(H)/b)
mid = (top+bot)//2
while(top-bot>1):
    if enough(mid):
        top = mid
    else:
        bot = mid
    mid = (top+bot)//2
#print(bot,mid,top)
print(top)

Submission status: Wrong Answer

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

def judge(t):
    count = 0
    Bt = B * t
    for i in range(N):
        numerator = h[i] - Bt
        count += max(math.ceil(numerator / C), 0)
    return count <= t

left = 0
right = math.ceil(10**9 // B)
mid = (left + right) // 2
while right - left > 1:
    if judge(mid):
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
print(right)

Submission status: Wrong Answer

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

if max(h) <= A:
    print(1)
    exit()

def judge(t):
    count = 0
    Bt = B * t
    for i in range(N):
        numerator = h[i] - Bt
        count += max(math.ceil(numerator / C), 0)
    return count <= t

left = 0
right = math.ceil(10**9 // B)
mid = (left + right) // 2
while right - left > 1:
    if judge(mid):
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
print(right)

Submission status: Wrong Answer

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

if max(h) <= A:
    print(1)
    exit()

def judge(t):
    count = 0
    Bt = B * t
    for i in range(N):
        numerator = h[i] - Bt
        count += math.ceil(numerator / C)
        if numerator % C != 0:
            count += 1
    return count <= t

left = 0
right = math.ceil(10**9 // B)
mid = (left + right) // 2
while right - left > 1:
    if judge(mid):
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
print(right)

Submission status: Wrong Answer

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

if max(h) <= A:
    print(1)
    exit()

def judge(t):
    count = 0
    Bt = B * t
    for i in range(N):
        count += math.ceil((h[i] - Bt) / C)
    return count <= t

left = 0
right = math.ceil(10**9 // B)
mid = (left + right) // 2
while right - left > 1:
    if judge(mid):
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
print(right)

Submission status: Wrong Answer

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

if max(h) <= A:
    print(1)
    exit()

def judge(t):
    count = 0
    Bt = B * t
    for i in range(N):
        count += math.ceil((h[i] - Bt) / C)
    return count <= t

def bisect(left, right, left_judge, right_judge):
    mid = (left + right) // 2
    mid_judge = judge(mid)
    if mid - left == 1 and left_judge != mid_judge:
        return mid
    if right - mid == 1 and mid_judge != right_judge:
        return right
    if mid_judge is True:
        return bisect(left, mid, left_judge, mid_judge)
    else:
        return bisect(mid, right, mid_judge, right_judge)

left = 1
right = 10**9 // B
left_judge = judge(left)
right_judge = judge(right)
result = bisect(left, right, left_judge, right_judge)
print(result)

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil
n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]

def enough(t):
    cnt = 0
    for h in H:
        # 全体攻撃を受けた残りHP
        rh = h - b * t
        if rh <= 0:
            continue
        cnt += rh // (a-b)
        if rh % (a-b) != 0:
            cnt += 1
    if cnt <= t:
        return True
    else:
        return False

min_ = ceil(sum(H)/(a+(n-1)*(a-b)))
if enough(min_):
    print(min_)
    sys.exit(0)
max_ = min_ * 2
while(enough(max_) == False):
    max_ *= 2

mid = (max_ + min_) // 2
while(max_ - min_ > 1):
    if enough(mid):
        max_ = mid
    else:
        min_ = mid
    mid = (max_ + min_) // 2
print(max_)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

N,A,B = map(int,input().split())
d = A-B
health = [-int(input()) for i in range(N)]
heapq.heapify(health)

count = 0
while True:
	pop = heapq.heappop(health)
	if pop >= -count*B:
		break
	heapq.heappush(health,pop+2)
	count += 1

print(count)

Submission status: Wrong Answer

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

q = a- b
ss = max(teki)

m =0
for i in range(n):
    u = teki[i] // b  + 1
    if m <= u:
        m = u

for i in range(n):
    teki[i] = teki[i] - b * (m)
    if teki[i] <= 0:
        teki[i] == 0
ans += m


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


"""
print(ans-1)

Submission status: Wrong Answer

Solution code:
import math
n, a, b=[int(i) for i in input().split()]
ab=a-b
t=[int(input()) for i in range(n)]
mx = sum([i//a for i in t])
mi = 1

while mx - mi != 1:
  i = (mx + mi) // 2
    
  ti= [j- i * b for j in t]
  if sum([max(math.ceil(j/ab),0) for j in ti]) <= i:
    mx = i
  else:
    mi = i
  
print(mx)

Submission status: Wrong Answer

Solution code:
import math
n, a, b=[int(i) for i in input().split()]
ab=a-b
t=[int(input()) for i in range(n)]
mx = max(t)//b + 1
mi = 1

while mx-mi>1:    
  i = (mx + mi) // 2
    
  ti= [j- i * b for j in t]
  if sum([max(math.ceil(j/ab),0) for j in ti]) <= i:
    mx=i
  else:
    mi=i
print(mx)

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int,input().split())
monster = [int(input()) for _ in range(n)]
hp = sum(monster)

attack = a + b * (n - 1)
ans = math.ceil(hp / attack)
if a > b * (n - 1):
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

add_damage = A-B
left = 1
right = 10**9
ans = float('inf')

for i in range(int(math.log(10**9, 2)+1)):
    T = (left+right) // 2
    h = H.copy()
    h = list(map(lambda x: max(0, x-T*B), h))
    h = list(map(lambda x: math.ceil(x / add_damage), h))
    need = sum(h)
    print(h, T)
    if need <= T:
        right = T
        ans = min(ans, T)
    else:
        left = T

print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

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

add_damage = A-B
left = 1
right = 10**9
ans = float('inf')

for i in range(int(math.log(10**9, 2))):
    T = (left+right) // 2
    h = H.copy()
    h = list(map(lambda x: max(0, x-T*B), h))
    h = list(map(lambda x: math.ceil(x / add_damage), h))
    need = sum(h)
    if need <= T:
        right = T
        ans = min(ans, T)
    else:
        left = T

print(ans)

Submission status: Wrong Answer

Solution code:
def d_Widespread(N, A, B, H):
    from math import ceil
    low = 0
    high = max(H) // B + 1  # 多くともこの回数だけ魔法を使えば全滅できる

    def enough(t):
        time = 0
        for h in H:
            time += ceil((h - B * t) / (A - B))
        if time <= t:
            return True
        else:
            return False

    while high - low > 1:
        mid = (low + high) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
    return high

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

Submission status: Wrong Answer

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


total_damage = a + b * (n-1)

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

d, m = divmod(sum(xs), total_damage)

if m == 0:
    print(d)
else:
    print(d+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import pdb
import copy

def main():
    '''
    N: number of monsters
    A: point blank
    B: spread damage
    '''
    [N, A, B] = map(int, raw_input().split(' '))
    HPs = np.zeros(N)
    for k in range(N):
        HPs[k] = int(raw_input())

    #answer = strategy(HPs, A, B)
    answer = strategy2(HPs, A, B)
    print answer

def strategy(HPs, A, B):
    turn = 0
    while max(HPs) > 0:
        HPs = np.sort(HPs)[::-1]
        HPs[0]= HPs[0] - (A - B)
        HPs = HPs - B
        turn += 1
    return turn


def strategy2(HPs, A, B):
    '''
    For binary search, I need to check three values;
    middle, top, and bottom.
    [x o o] will induce the middle to take over the top
    and [x x o] will induce the middle to take over the ttom. 
    '''


    maxT = np.ceil(np.max(HPs)/B)
    minT = 0
    check = True

    while(check):
        midT = np.ceil((maxT + minT)/2)
        checkvalues = np.array([minT, midT, minT])
        top = testmyT(HPs, A, B, maxT)
        middle = testmyT(HPs, A, B, midT)
        bottom = testmyT(HPs, A, B, minT)
        checkbools = [bottom, middle, top]
        #pdb.set_trace()
        if (not middle) and (not bottom):
            minT = midT
        if top and middle:
            maxT = midT
        if maxT - minT <= 1.:
            check = False
    return np.int(maxT)



def testmyT(HPs, A, B, T):
    threshold = np.ceil((HPs - B*T)/(A-B))
    threshold = np.sum(threshold)
    return (threshold <= T)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

N, A, B = map(int, raw_input().split())
h = [int(raw_input()) for _ in xrange(N)]

def judge(K):
    sums = 0
    for i in h:
        t = i-K*B
        if t > 0:
            sums += math.ceil(t*1.0/(A-B))
            if sums > K:
                return False;
    return True

high = math.ceil(max(h)/B)
low = 0

while high > low:
    mid = int((high + low) / 2)
    if judge(mid):
        high = mid;
    else:
        low = mid+1;

print low

Submission status: Wrong Answer

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

C=A-B
sum,d=0,10**10
T = min(H)//C+1
lasT = T*2
while 1:
    sum = 0
    if d == 1:
        break
    for i in range(N):
        if H[i]-B*T > 0:
            sum += (H[i]-B*T)//C+1
    d = abs(T-lasT)
    lasT = T
    if sum <= T:
        T = T - d//2
    else:
        T = T + d//2

print(T-1)

Submission status: Wrong Answer

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

ans = h
cnt = 0

while ans:
    max_ind = ans.index(max(ans))
    ans[max_ind] -= A
    
    for i in range(len(ans)):
        if i != max_ind:
            ans[i] -= B
    ans = [x for x in ans if x > 0]
#    ans.sort()
#    ans.reverse()
    print(ans)
    cnt += 1

print(cnt)

Submission status: Wrong Answer

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

ans=0
while any(i>=0 for i in h_n):
    h_n=[i-B for i in h_n]
    h_n[h_n.index(max(h_n))]+=B-A
    ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, A, B = map(int, input().split())
M = [int(input()) for i in range(N)]
d = A - B
ans = 0
while not all([True if m <= 0 else False  for m in M]):
    mx = max(M)
    CM = Counter(M)
    c = CM[mx]
    if c == N:
        j = A+(c - 1)*B
        if j > mx:
            break
        else:
            l = mx // j
            p = l * c
            ans += p
            M = [m - j*l for m in M]
    else:
        temp = list(set(M) - set([mx]))
        if d > (mx - max(temp)):
            break
        k = (mx - max(temp)) // d
        ans += c * k
        for i in range(N):
            if M[i] == mx:
                M[i] = M[i] - k * (A+(c-1)*B)
            else:
                M[i] = M[i] - k * c * B

print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))
    
left = 1
right = max(h)//B + 1

while right - left > 1:
    mid = (right + left) // 2
    c = sum([ceil((hi-mid*B)/(A-B)) for hi in h if hi > mid * B])
    if c > mid:
        left = mid
    else:
        right = mid
        
print(right)

Submission status: Wrong Answer

Solution code:
from math import ceil

N, A, B = map(int, input().split())
H = []
for _ in range(N):
    H.append(int(input()))
    
left = 0
right = max(H)//B + 1

while right - left > 2:
    mid = (right + left) // 2
    c = sum([ceil((h-B*mid)/(A-B)) for h in H if h > B*mid])
    
    if c > mid:
        left = mid
    else:
        right = mid
print(right)

Submission status: Wrong Answer

Solution code:
from math import ceil

N, A, B = map(int, input().split())
H = []
for _ in range(N):
    H.append(int(input()))
    
left = 0
right = max(H)//B + 1

while right - left > 2:
    mid = (right + left) // 2
    c = sum([ceil((h-B*mid)/(A-B)) for h in H if h > B*mid])
    
    if c > mid:
        left = mid
    else:
        right = mid
print(left+1)

Submission status: Wrong Answer

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

H = []
for _ in range(N):
    H.append(int(input()))
 
    
sup = max(H) // B + 1
inf = 1
 
while sup - inf > 1:
    t = (sup + inf) // 2
    c = sum([math.ceil((h - t * B)/(A-B)) for h in H if h > t * B])
    if c <= t:
        sup = t
    else:
        inf = t

print(sup)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,A,B = map(int , raw_input().split())
#print N,A,B
b = [0 for i in range(N)]
h = [0 for i in range(N)]
for i in range(N):
	b[i] = raw_input()
	h[i] = int(b[i])


cnt = 0
a = 0
while any(h) == True:	
	h.sort()
	for i in range(N):
		if h[N-1] != h[N-i-1]:
			a = h[N-i-1]
			break
	c = (h[N-1] - a) / (A - B)
	if c == 0:
		c = 1
	cnt = cnt + c
	for i in range(N):
		if h[N-1] == h[i]:
			h[i] = h[i] - A*c
		else:
			h[i] = h[i] - B*c
		if h[i] < 0:
			h[i] = 0

print cnt

Submission status: Wrong Answer

Solution code:
import numpy as np
N,A,B = map(int , raw_input().split())
#print N,A,B
b = [0 for i in range(N)]
h = [0 for i in range(N)]
for i in range(N):
	b[i] = raw_input()
	h[i] = int(b[i])


cnt = 0
a = 0
while any(h) == True:	
	h.sort()
	for i in range(N):
		if h[N-1] != h[N-i-1]:
			a = h[N-i-1]
			break
	c = (h[N-1] - a) / (A - B) + 1
	cnt = cnt + c
	for i in range(N):
		if h[N-1] == h[i]:
			h[i] = h[i] - A*c
		else:
			h[i] = h[i] - B*c
		if h[i] < 0:
			h[i] = 0

print cnt

Submission status: Wrong Answer

Solution code:
import numpy as np
N,A,B = map(int , raw_input().split())
#print N,A,B
b = [0 for i in range(N)]
h = [0 for i in range(N)]
for i in range(N):
	b[i] = raw_input()
	h[i] = int(b[i])

print h
cnt = 0
a = 0
while any(h) == True:	
	h.sort()
	print h
	for i in range(N):
		if h[N-1] != h[N-i-1]:
			a = h[N-i-1]
			break
	c = (h[N-1] - a) / (A - B) + 1
	cnt = cnt + c
	for i in range(N):
		if h[N-1] == h[i]:
			h[i] = h[i] - A*c
		else:
			h[i] = h[i] - B*c
		if h[i] < 0:
			h[i] = 0

print cnt

Submission status: Wrong Answer

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

import numpy as np
import math as m

nh = np.array(h)

def testATK(ary, num, a, b):
    ary = np.array(ary)
    atk1 = b*num
    tmp = ary - atk1
    bommed = []
    for e in tmp:
        if(e>0):
            bommed.append(e)
    bommed = np.array(bommed)
    atk2 = a-b
    bomneed = list(map(m.ceil, (bommed/atk2)))
    acnt = np.sum(bomneed)
    if acnt > num:
        return "NO"
    else:
        return "YES"

imin = 1
imax = m.ceil(max(nh)/b)

def bs(ary, imin, imax):
    if (imax < imin):
        return imin
    else:
        imid = imin + (imax - imin)//2
        if (testATK(nh,imid,a,b)=="YES"):
            return bs(ary, imin, imid - 1)
        elif (testATK(nh,imid,a,b)=="NO"):
            return bs(ary, imid + 1, imax)
bs(nh, imin, imax)

Submission status: Wrong Answer

Solution code:
# Widespread
n,a,b = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))
import numpy as np
hh = np.array(sorted(h))
cnt = 0
while ( len(hh)!=0 ):
    #print(hh)
    if ( cnt > 100):
        break
    hh = hh - b
    hh[np.argmax(hh)] -= (a-b)
    cnt+=1
    hh = np.array(sorted(hh))
    #print(hh)
    while ( len(hh)>0 and hh[0]<1 ):
        hh = np.delete(hh, 0)
        if ( len(hh)<0 ):
            break   
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

if n == 1:
    print(math.ceil(h[0] / a))
else:
    m1 = h[-1]
    m2 = h[-2]
    ans = 0
    while m1 > 0 or m2 > 0:
        ans += 1
        if m1 >= m2:
            m1 -= a
            m2 -= b
        else:
            m2 -= a
            m1 -= b
    print(ans)

Submission status: Wrong Answer

Solution code:
import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return True
    else:
        return False

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

H = sorted([int(input()) for i in range(tmp[0])])[::-1]
minT = 0
maxT = H[0] // b + 1
T = int((maxT + minT) / 2)

while True:
    T = math.ceil((maxT + minT) / 2)
    if calc(H, T, a, b):
        maxT = T
    else:
        minT = T
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
import sys

line = input().split(' ')
N = int(line[0])
A = int(line[1])
B = int(line[2])
hn = sorted([int(input()) for i in range(N)])

maxT = int(hn[-1] / B) + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) for h in hn])
    return True if count <= T else False

while True:
    med = int((maxT + minT) / 2)
    if maxT + minT % 2 == 0:
        flag = True
    else:
        flag = False
        
    if enough(med):
        maxT = med
    else:
        minT = med
    if flag:
        if maxT - minT == 0:
            break
    else:
        if maxT - minT == 1:
            break
print(maxT)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
import sys

line = input().split(' ')
N = int(line[0])
A = int(line[1])
B = int(line[2])
hn = sorted([int(input()) for i in range(N)])

maxT = math.ceil(hn[-1] / B)
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) for h in hn])
    return True if count <= T else False

while True:
    med = int((maxT + minT) / 2)
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
import sys

line = input().split(' ')
N = int(line[0])
A = int(line[1])
B = int(line[2])
hn = sorted([int(input()) for i in range(N)])

maxT = int(max(hn) / B) + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) for h in hn])
    return True if count <= T else False

while True:
    med = int((maxT + minT) / 2)
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
import sys

line = input().split(' ')
N = int(line[0])
A = int(line[1])
B = int(line[2])
hn = sorted([int(input()) for i in range(N)])

maxT = int(max(hn) / B)
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) for h in hn])
    return True if count <= T else False

while True:
    med = math.ceil((maxT + minT) / 2)
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
import sys

line = input().split(' ')
N = int(line[0])
A = int(line[1])
B = int(line[2])
hn = sorted([int(input()) for i in range(N)])
# print(hn)
# print(hn[-1])
# print(max(hn))

maxT = int(max(hn) / B)
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) for h in hn])
    # print([math.ceil((h - B*T) / (A-B)) for h in hn])
    # print(count)
    return True if count <= T else False

while True:
    # print('maxT:' + str(maxT))
    med = int((maxT + minT) / 2)
    # print('med:' + str(med))
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Wrong Answer

Solution code:
import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return True
    else:
        return False

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

H = sorted([int(input()) for i in range(tmp[0])])[::-1]
minT = 0
maxT = math.ceil(H[0] / b)
T = int((maxT + minT) / 2)

while True:
    T = math.ceil((maxT + minT) / 2)
    if calc(H, T, a, b):
        maxT = T
    else:
        minT = T
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Wrong Answer

Solution code:
import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return True
    else:
        return False

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

H = sorted([int(input()) for i in range(tmp[0])])
minT = 0
maxT = math.ceil(H[0] / b)
T = int((maxT + minT) / 2)

while True:
    T = int((maxT + minT) / 2)
    if calc(H, T, a, b):
        maxT = T
    else:
        minT = T
    if maxT - minT <= 1:
        break
print(maxT)

Submission status: Wrong Answer

Solution code:
import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return True
    else:
        return False

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

for i in range(tmp[0]):
    H.append(int(input()))
H = list(sorted(H))[::-1]
minT = 0
maxT = math.ceil(H[0] / b)
T = int((maxT + minT) / 2)

while True:
    T = int((maxT + minT) / 2)
    if calc(H, T, a, b):
        maxT = T
        if maxT - minT <= 1:
            break
    else:
        minT = T
print(T)