Problem:


Score : 400 points

Problem Statement

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

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

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

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

Constraints

All input values are integers.

1 ≤ N ≤ 10^5

1 ≤ B < A ≤ 10^9

1 ≤ h_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N A B
h_1
h_2
:
h_N

Output

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

Sample Input 1

4 5 3
8
7
4
2

Sample Output 1

2

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

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

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

Sample Input 2

2 10 4
20
20

Sample Output 2

4

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

Sample Input 3

5 2 1
900000000
900000000
1000000000
1000000000
1000000000

Sample Output 3

800000000



Sample input:
4 5 3
8
7
4
2


Sample output:
2

Submission status: Wrong Answer

Solution code:
import 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
    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 = 1
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 = 1
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:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
	return a * b // gcd (a, b)

def calc(H):
    cnt = 0
    while True:
        H = list(sorted(H))[::-1]
        flg = 0
        cnt += 1
        H[0] = H[0] - a
        for i in range(len(H)):
            if i == 0:
                if H[0] > 0:
                    flg = 1
                continue
            H[i] = H[i] - b
            if H[i] > 0:
                flg = 1
        if flg == 0:
            break
    return cnt

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]
gc = H[0]
for h in H:
    gc = gcd(gc,h)

lc = lcm(a,b)

scale = max(1,int(gc / lc))

H = list(map(lambda n: int(n / scale), H))

cnt = calc(H) * scale
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

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)
mini = min(hn)
syo = int(mini / A)
if syo == 0:
    syo = 1

hn_s = [i / syo for i in hn]
i = 0
# print(hn_s)
while True:
    hn_s = [i - B for i in hn_s]
    hn_s[-1] -= A - B
    if all([True if i <= 0 else False for i in hn_s]):
        break
    sorted(hn_s)
    i += 1
i -= 1
i *= syo
print(i)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def calc(H):
    cnt = 0
    while True:
        H = list(sorted(H))[::-1]
        flg = 0
        cnt += 1
        H[0] = H[0] - a
        for i in range(len(H)):
            if i == 0:
                if H[0] > 0:
                    flg = 1
                continue
            H[i] = H[i] - b
            if H[i] > 0:
                flg = 1
        if flg == 0:
            break
    return cnt

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]
gc = H[0]
for h in H:
    gc = gcd(gc,h)

H = list(map(lambda n: int(n / gc), H))

cnt = calc(H) * gc
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

import numpy as np


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


def enough(T):
    h2 = list(map(lambda x: x - B * T, h))
    return sum(map(lambda x: max(0, math.ceil(x / (A - B))), h2)) <= T


def solver(mi, ma):
    mid = (mi + ma) // 2
    if mi == ma:
        return mid
    elif enough(mid):
        return solver(mi, mid)
    else:
        return solver(mid + 1, ma)


t = max(h) // B

print(solver(0, t))

Submission status: Wrong Answer

Solution code:
import math

import numpy as np


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


def enough(T):
    h2 = list(map(lambda x: x - B * T, h))
    print(h2)
    return sum(map(lambda x: max(0, math.ceil(x / (A - B))), h2)) <= T


def solver(mi, ma):
    print(mi, ma)
    mid = (mi + ma) // 2
    if mi == ma:
        return mid
    elif enough(mid):
        return solver(mi, mid)
    else:
        return solver(mid + 1, ma)


t = max(h) // B

print(solver(0, t))

Submission status: Wrong Answer

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

def enough(T):
    bt = B * T
    ab = A - B
    atk = [(v - bt) / ab for v in h if v > bt]
    print atk
    add = sum([v for v in atk if v > 0])
    if add <= T:
        return True
    return False

l = 0
r = max(h) / B + 1
while r - l > 1:
    T = (l + r) / 2
    print l, r, T
    if enough(T):
        r = T
    else:
        l = T
if r == 2:
    if enough(1):
        r = 1
print r

Submission status: Wrong Answer

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

def enough(T):
    bt = B * T
    ab = A - B
    atk = sum([(v - bt) / ab + 1 for v in h if v > bt])
    if atk <= T:
        return True
    return False

l = 0
r = max(h) / B + 1
while r - l > 1:
    T = (l + r) / 2
    if enough(T):
        r = T
    else:
        l = T
if r == 2:
    if enough(1):
        r = 1
print r

Submission status: Wrong Answer

Solution code:
from math import log10
N, A, B = map(int, raw_input().split(' '))
h = [float(raw_input()) for _ in range(N)]

n = max(0, int(log10(min(h))) - int(log10(A)))
if n > 0:
    h = [v / 10 ** n for v in h]

itr = 0
while max(h) > 0:
    h = [v - B for v in sorted(h)]
    h[-1] -= A - B
    itr += 1

print itr * 10 ** n

Submission status: Wrong Answer

Solution code:

import numpy as np

N, A, B = (int(e) for e in input().split())

ary = np.zeros(N)
for i in range(N):
    ary[i] = int(input())


###

print(ary)
d = A - B
cnt = 0
while np.any(ary > 0):
    idx = np.argmax(ary)
    ary -= B
    ary[idx] -= d
    print(ary)
    cnt += 1

print(cnt)

### TLE

Submission status: Wrong Answer

Solution code:
import heapq

def f(A, B, hs):
    hs = [-h for h in hs]
    heapq.heapify(hs)
    iterations = 0
    while hs[0] < 0:
        hi = heapq.heappop(hs)
        hs = [h + B for h in hs]
        heapq.heappush(hs, hi + A)
        iterations += 1
    return iterations

N, A, B = map(int, input().split())
hs = []
for _ in range(N):
    hs.append(int(input()))
f(A, B, hs)

Submission status: Wrong Answer

Solution code:
import math

n,a,b = [int(x) for x in input().split()]

monsters_hp = sorted([int(input()) for _ in range(n)])

sum_monsters_hp = sum(monsters_hp)

def is_enough(t):
	count = 0
	bb = b*t
	for i in monsters_hp:
		if i <= bb:
			pass
		else:
			count += math.ceil((i-bb)/(a-b))
	if count <= t:
		return True
	else:
		return False

search_min = 1
search_max = math.ceil(sum_monsters_hp/a)

while search_max - search_min > 1:
	pointer = (search_max+search_min)//2
	if is_enough(pointer):
		search_max = pointer
	else:
		search_min = pointer

ans = search_max

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n,a,b = [int(x) for x in input().split()]

monsters_hp = sorted([int(input()) for _ in range(n)])

sum_monsters_hp = sum(monsters_hp)

def is_enough(t):
	count = 0
	bb = b*t
	for i in monsters_hp:
		if i <= bb:
			pass
		else:
			count += math.ceil((i-bb)/(a-b))
	if count <= t:
		return True
	else:
		return False

search_min = 1
search_max = math.ceil(sum_monsters_hp/a)

while search_max - search_min != 1:
	pointer = (search_max+search_min)//2
	if is_enough(pointer):
		search_max = pointer
	else:
		search_min = pointer

ans = search_max

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n,a,b = [int(x) for x in input().split()]

monsters_hp = sorted([int(input()) for _ in range(n)])

sum_monsters_hp = sum(monsters_hp)

def is_enough(t):
	count = 0
	bb = b*t
	for i in monsters_hp:
		if i <= bb:
			pass
		else:
			count += math.ceil((i-bb)/(a-b))
	if count <= t:
		return True
	else:
		return False

search_min = 0
search_max = math.ceil(sum_monsters_hp/a)

while search_max - search_min != 1:
	pointer = (search_max+search_min)//2
	if is_enough(pointer):
		search_max = pointer
	else:
		search_min = pointer

ans = search_max

print(ans)

Submission status: Wrong Answer

Solution code:
#!/bin/usr/python

def gcd(a , b):
  while b:
    a, b = b, a % b
  return a

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

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

for i in range(n):
  h[i] /= pad

h = sorted(h, reverse = True)

while True:
  count += 1
  h[0] -= a
  for i in range(1,n):
    h[i] -= b
    if h[i] <= 0:
      h[i] = 0

  if sum(h) <= 0:
    break

  h = sorted(h, reverse = True)

print(count * pad)

Submission status: Wrong Answer

Solution code:
def check(N,A,B,h,K):
    sum = 0
    for i in range(N):
        x = -((-h[i]+B*K)/(A-B))
        sum += x if x>0 else 0
    return sum<=K

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

ok = 1000000000
ng = 0
while abs(ok -ng)>1:
    mid = (ok+ng)//2
    if check(N,A,B,h,mid):
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Wrong Answer

Solution code:
def check(N,A,B,h,K):
    sum = 0
    for i in range(N):
        x = -((-h[i]+B*K)/(A-B))
        sum += x if x>0 else 0
    return sum<K

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

ok = 1000000000
ng = 0
while abs(ok -ng)>1:
    mid = (ok+ng)//2
    if check(N,A,B,h,mid):
        ok = mid
    else:
        ng = mid
print(ok)

Submission status: Wrong Answer

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

def bs(n, a, b, hp, min=0, max=10**5):
    left = min
    right = max
    def count(num):
        base = b * num
        attackcount = 0
        diff = a-b
        for i in range(n):
            tmp = math.ceil((hp[i] - base) / diff)
            if tmp <= 0:
                pass
            else:
                attackcount += tmp
        if attackcount <= num:
            return True
        else:
            return False
    while left != right:
        mid = (left + right) // 2
        if count(mid):
            right = mid
        else:
            left = mid + 1
    return left

if __name__ == '__main__':
    n, a, b = map(int, input().split())
    hp = [int(input()) for i in range(n)]
    print(bs(n, a, b, hp))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

i = 0
while True:
    sorted(h)
    if sorted(h)[-1] <= 0:
        print(i)
        break
    else:
        i += 1
        sorted(h)[-1] -= (A-B)
        h = [ h[j] - B for j in range(len(h)) ]

Submission status: Wrong Answer

Solution code:
#coding=UTF-8
myon_chache={}
def turn_check(zikan,direct,around):
    nokori_naka=zikan
    for idx in range(0,N,1):
        rem_hp=kirei_HP[idx]-around*zikan
        if rem_hp > 0:
            if rem_hp in myon_chache:
                myon=myon_chache[rem_hp]
            else:
                myon= rem_hp//(direct-around) + (0 if rem_hp%(direct-around)==0 else 1)
                myon_chache[rem_hp]=myon
        
            nokori_naka=nokori_naka-myon
            if nokori_naka < 0:
                return False
        else: #以降も周辺攻撃のみで倒せる
            return True

    return True


mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
A=int(hyo[1])
B=int(hyo[2])

HP=[]
for idx in range(0,N,1):
    HP.append(int(input()))

kirei_HP=sorted(HP,reverse=True)
dmg_mean= B + (A-B)//N
kagen=kirei_HP[0]// dmg_mean + 1
tansaku=kagen//2
ite=0
dame_jogen=0
while True:
    ite=ite+1
    if turn_check(tansaku,A,B):
        kagen=tansaku
        tansaku=(kagen+dame_jogen)//2
    else:
        if tansaku + 1 == kagen: #丁度境目を見付けたら
            break
        else:
            dame_jogen=tansaku
            tansaku=(tansaku+kagen)//2

#print(ite)
print(kagen)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, A, B = map(int, input().split())
e = np.array([int(input()) for _ in range(N)]).astype('int64')

s = A - B
z = B
hM = np.max(e)
T = hM // z + 1
D = T

left = 0
right = 10**9

def is_enough(T):
    j = e - T * z
    j[j<0]=0
    mod = j % s
    c_mod = np.sum(mod > 0)
    jem = j - mod 
    c_div = np.sum(jem) // s
    nc = c_mod + c_div
    return nc <= T

while abs(left - right) > 1:

    D = D // 2 + D % 2
    b= is_enough(T)
    if b:
        T -= D
        left = T
    else:
        T += D
        right = T

if is_enough(left):
    print(left)
else:
    print(right)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    count+=max(0,-int(-(S[i]-B*T)/(A-B)))
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
    final=1
  elif Check(T)==0:
    T+=2**(l-1)
    final=0
print(T+final)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    count+=max(0,-int(-(S[i]-B*T)/(A-B)))
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
    final=1
  elif Check(T)==0:
    T+=2**(l-1)
    final=1
print(T+final)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    count+=max(0,-int(-(S[i]-B*T)/(A-B)))
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
while L>0:
  if Check(T)==1:
    L-=1
    T-=2**L
    final=1
  elif Check(T)==0:
    L-=1
    T+=2**L
    final=1
print(T+final)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    count+=-int(-(S[i]-B*T)/(A-B))
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
while L>0:
  if Check(T)==1:
    L-=1
    T-=2**L
    final=1
  elif Check(T)==0:
    L-=1
    T+=2**L
    final=1
print(T+final)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    count+=int((S[i]-B*T)/(A-B))
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >= 2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
while L>0:
  if Check(T)==1:
    L-=1
    T-=2**L
    final=1
  elif Check(T)==0:
    L-=1
    T+=2**L
    final=1
print(T+final)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    count+=int((S[i]-B*T)/(A-B))
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B > 2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
while L>0:
  if Check(T)==1:
    L-=1
    T-=2**L
    final=1
  elif Check(T)==0:
    L-=1
    T+=2**L
    final=1
print(T+final)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, A, B = map(int, input().split())
e = np.array([int(input()) for _ in range(N)]).astype('int64')

s = A - B
z = B
hM = np.max(e)
T = hM // z + 1
D = T

while True:
    j = e - T * z
    j[j<0]=0
    mod = j % s
    c_mod = np.sum(mod > 0)
    jem = j - mod 
    c_div = np.sum(jem) // s
    nc = c_mod + c_div
    D = D // 2 + D % 2
    if nc > T:
        T += D
    elif nc < T:
        T -= D
        if D == 1:
            break
    else:
         break
 
print(T )

Submission status: Wrong Answer

Solution code:
#coding=UTF-8

def turn_check(zikan,direct,around):
    nokori_naka=zikan
    for idx in range(0,N,1):
        rem_hp=HP[idx]-around*zikan
        myon= rem_hp//(direct-around) + (0 if rem_hp%(direct-around)==0 else 1)
        
        nokori_naka=nokori_naka-myon
        if nokori_naka < 0:
            return False

    return True


mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
A=int(hyo[1])
B=int(hyo[2])

HP=[]
for idx in range(0,N,1):
    HP.append(int(input()))

kagen=max(HP)// B + 1
tansaku=kagen//2
while True:
    if turn_check(tansaku,A,B):
        kagen=tansaku
        tansaku=kagen//2
    else:
        if tansaku + 1 == kagen: #丁度境目を見付けたら
            break
        else:
            tansaku=(tansaku+kagen)//2

print(kagen)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, a, b = map(int, raw_input().split())
h = []
for i in xrange(n):
    h.append(int(raw_input()))
h = np.array(h)
count = 0
adiff = float(a - b)
top = max(h) / b
bottom = 0
mid = top / 2
while(1):
    if top - bottom < 2:
        break
    hmem = h - b * mid
    if np.sum(np.ceil(hmem[hmem >= 0] / adiff)) <= mid:
        top = mid
    else:
        bottom = mid
    mid = (top + bottom) / 2
print top

Submission status: Wrong Answer

Solution code:
import numpy as np
n, a, b = map(int, raw_input().split())
h = []
for i in xrange(n):
    h.append(int(raw_input()))
h = np.array(h)
count = 0
adiff = float(a - b)
top = max(h) / b
bottom = 0
mid = top / 2
while(1):
    if top - bottom < 2:
        break
    hmem = h - b * mid
    if int(np.sum(np.ceil(hmem[hmem > 0] / adiff))) <= mid:
        top = mid
    else:
        bottom = mid
    mid = (top + bottom) / 2
print top

Submission status: Wrong Answer

Solution code:
import math

def check(x):
    k = 0
    global h, a, b
    for i in h:
        if x * b < i:
            k += math.ceil((i - x * b) / (a - b))
    return k <= x


n, a, b = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
l = -1
r = max(h) // b
while r - l > 1:
    m = (l + r) // 2
    if check(m):
        r = m
    else:
        l = m
print(r)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, a, b = map(int, raw_input().split())
h = []
for i in xrange(n):
    h.append(int(raw_input()))
h = np.array(h)
count = 0
adiff = float(a - b)
top = max(h) / b
bottom = 0
mid = top / 2
while top - bottom > 2:
    hmem = h - b * mid
    if int(np.sum(np.ceil(hmem[hmem > 0] / adiff))) <= mid:
        top = mid
    else:
        bottom = mid
    mid = (top + bottom) / 2
print top

Submission status: Wrong Answer

Solution code:
import numpy as np
n, a, b = map(int, raw_input().split())
h = []
for i in xrange(n):
    h.append(int(raw_input()))
h = np.array(h)
count = 0
adiff = float(a - b)
top = max(h) / b
bottom = 0
mid = top / 2
while(1):
    hmem = h - b * mid
    if int(np.sum(np.ceil(hmem[hmem > 0] / adiff))) <= mid:
        top = mid
    else:
        bottom = mid
    mid = (top + bottom) / 2
    if top - bottom <= 1:
        break
print top

Submission status: Wrong Answer

Solution code:
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

# print count
def solve(count, hpList):
	q = hpList - b * count
	t = q > 0

	if a > b:
		p = (q - 1) / (a - b) + 1
	else:
		p = q
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
if r - l == 1:
	r = 1
while r - l > 1:
	m = (l + r) / 2
	if solve(m, ll):
		r = m
	else:
		l = m

print r

Submission status: Wrong Answer

Solution code:
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

# print count
def solve(count, hpList):
	q = hpList - b * count
	t = q > 0

	if a > b:
		p = (q - 1) / (a - b) + 1
	else:
		p = q
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(m, ll):
		r = m
	else:
		l = m

print r

Submission status: Wrong Answer

Solution code:
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

# print count
def solve(count, hpList):
	q = hpList - b * count
	t = q > 0
	p = (q - 1) / (a - b) + 1
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(m, ll):
		r = m
	else:
		l = m

print r

Submission status: Wrong Answer

Solution code:
n, A, B = map(int, input().split())
l = [int(input()) for x in range(n)]

left = 0
right = 10**9


def is_ok(t):
    return sum(map(lambda x: max(0, x - B*t) // (A - B), l)) <= t


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

print([right, left][is_ok(left)])

Submission status: Wrong Answer

Solution code:
n, A, B = map(int, input().split())
l = [int(input()) for x in range(n)]

left = 0
right = 10**9


def is_ok(t):
    return all(map(lambda x: max(0, x - B*t) <= t, l))


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

print([right, left][is_ok(left)])

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
count=0

def Check(T):
  count=0
  for i in range(N):
    count+=int((S[i]-B*T)/(A-B))
  if count<=T:
    return 1
  else:
    return 0

L=0#二分探索の指数
T=1#checkしたいナンバー。
while True:
  if Check(T)==0:
    L+=1
    T+=2**L
  if Check(T)==1:
    L-=1
    T-=2**L
    if L==0:
      print(T)
      sys.exit()

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

times = 0
while len(monster) > 0:
    print ('monster', monster)
    n = monster.index(max(monster)) #一番体力が大きい魔物のインデックス
    monster[n] = monster[n] - A
    if monster[n] < 1:
        monster[n] = 0

    for i, x in enumerate(monster):
        if i != n:
            monster[i] = monster[i] - B
            if monster[i] < 1:
                monster[i] = 0
    monster = [i for i in monster if i != 0]

    times = times + 1

print (times)

Submission status: Wrong Answer

Solution code:
n = input()
tmp_n = n.split(" ")

n = int(tmp_n[0])
a = int(tmp_n[1])
b = int(tmp_n[2])

hp = []
a_num = []
for i in range(n):
    p = input()
    hp.append(int(p))
    a_num.append(int(int(p)/a))

if n==1:
    print(int(hp[0]/a)+1)
else:
    hp.sort()
    if b*(int(hp[-1]/a)+1)>=hp[-2]:
        print(int(int(hp[-1]/a)+1))
    else:
        print(sum(a_num)-int(sum(a_num)/a))

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int, input().split()))
sumH = 0
minans = 0
for i in range(N):
    hi = int(input())
    sumH += hi
    minans += -1 * (-hi // A)


ans = -1 * (-sumH // (A + (N - 1) * B))
if (A-B) > B and ans < minans:
    ans = minans
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

def main():
    lst = sys.stdin.readline().split()
    n = int(lst[0])
    a = int(lst[1])
    b = int(lst[2])

    # h_lst = []
    h_sum = 0
    for i in range(n):
        t = int(sys.stdin.readline())
        h_sum += t
        # h_lst.append(t)

    cnt = math.ceil(h_sum / (a + (n-1) * b))
    print(cnt)

    # cnt = 0

    # while True:
    #     max_score = -1
    #     max_score_ind = -1
    #     #最大の体力を持つ魔物を探す
    #     for ind in range(n):
    #         if h_lst[ind] >= max_score:
    #             max_score = h_lst[ind]
    #             max_score_ind = ind

    #     #全滅したら終了
    #     if max_score <= 0:
    #         print(cnt)
    #         return 0

    #     #最大の体力を持つ魔物を中心に爆発
    #     for ind in range(n):
    #         if ind == max_score_ind:
    #             h_lst[ind] -= a
    #         else:
    #             h_lst[ind] -= b

    #     cnt += 1


    return 0

if __name__ == '__main__':
    sys.exit(main())

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
h = [int(input()) for i in range(N)]
H = sum(h)
C = A + B * (N - 1)
D = int(H / C)

print(D)

Submission status: Wrong Answer

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

while max(m) > 0:
    for i in range(len(m)):
        if m[i] > 0:
            if m[i] == max(m):
                m[i]= m[i] - a
            else:
                m[i]= m[i] - b
    attack += 1
print(attack)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
m=[]
for i in range(n):
    m.append(int(input()))
m.sort(reverse=True)

attack=0
#攻撃
while max(m) > 0:
    for i in range(len(m)):
        if m[i] == max(m):
            m[i]= m[i] - a
        else:
            m[i]= m[i] - b
    attack += 1
print(attack)

Submission status: Wrong Answer

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

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

enemy=N
counter=0

while enemy>0:
    if max(h)>=A*50:
        atk=h.index(max(h))
        num=int((max(h)-A)/(3*N))
        for i in range(N):
            h[i]-=(B*num)
        h[atk]+=(num*(B-A))
        counter+=num





    atk=h.index(max(h))
    for i in range(N):
        h[i]-=B
    h[atk]+=(B-A)
    counter+=1

    for i in range(N):
        if h[i]<=0:
            h[i]=0
            enemy-=1

 #   print(h)
print(counter)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

monster = list(int(input()) for i in range(n))
monster.sort(reverse = True)

c = b * np.ones(n)
c[0] = a

count = 0

for i in range(1000000) :
  monster = monster - c
  sorted(monster, key = int, reverse = True)
  count = count + 1
  if monster[0] <= 0 :
    break;

print (count)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N, A, B = ILI()
    h = [II() for __ in range(N)]
    return (N, A, B, h)


def bool_exc(h, dif_ab, B, count):
    dif_count = 0
    for mon in h:
        dif_mon = mon - B * count
        if dif_mon <= 0:
            continue
        else:
            dif_count += math.ceil(dif_mon / dif_ab)
            if dif_count > count:
                break

    dif = count - dif_count
    return dif


def solve(N, A, B, h):
    right = max(h) // B + 1
    left = min(h) // A + 1
    dif_ab = A - B
    while left != right:
        mid = (left + right) // 2
        dif = bool_exc(h, dif_ab, B, mid)
        if dif > 0:
            right = mid - 1
        elif dif == 0:
            right = mid
        elif dif < 0:
            left = mid + 1

    ans = left
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
N, A, B = list(map(int,input().split()))
H = []
for i in range(N):
    H.append(int(input()))
H = np.sort(H)[::-1]
attack = np.ones(N).astype(np.int64)
attack *= B
attack[0] = A
count = 0
p = int(H[0]/A)
order = 0
while p>=10:
    p /= 10
    order+=1
while H[0]>0:
    if H[0]/(A*10**(order)) > 1:
        H -= attack*10**(order)
        H = np.sort(H)[::-1]
        count += 10**(order)
    else:
        order -= 1
        if order<0:
            break
        H -= attack*10**(order)
        H = np.sort(H)[::-1]
        count += 10**(order)
while H[0]>0:
    H -= attack
    H = np.sort(H)[::-1]
    count += 1
print (count)

Submission status: Wrong Answer

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

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

enemy=N
counter=0

while enemy>0:
    if max(h)>=A*1000:
        atk=h.index(max(h))
        num=int((max(h)-A)/(3*N))
        for i in range(N):
            h[i]-=(B*num)
        h[atk]+=(num*(B-A))
        counter+=num





    atk=h.index(max(h))
    for i in range(N):
        h[i]-=B
    h[atk]+=(B-A)
    counter+=1

    for i in range(N):
        if h[i]<=0:
            h[i]=0
            enemy-=1

 #   print(h)
print(counter)