Problem:


Score : 400 points

Problem Statement

Snuke found N strange creatures.
Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively.

Every creature can absorb another creature whose size is at most twice the size of itself.
When a creature of size A and color B absorbs another creature of size C and color D (C \leq 2 \times A), they will merge into one creature of size A+C and color B.
Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other.

Snuke has been watching these creatures merge over and over and ultimately become one creature.
Find the number of the possible colors of this creature.

Constraints

2 \leq N \leq 100000

1 \leq A_i \leq 10^9

A_i is an integer.

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 … A_N

Output

Print the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature.

Sample Input 1

3
3 1 4

Sample Output 1

2

The possible colors of the last remaining creature are colors 1 and 3.
For example, when the creature of color 3 absorbs the creature of color 2, then the creature of color 1 absorbs the creature of color 3, the color of the last remaining creature will be color 1.

Sample Input 2

5
1 1 1 1 1

Sample Output 2

5

There may be multiple creatures of the same size.

Sample Input 3

6
40 1 30 2 7 20

Sample Output 3

4



Sample input:
3
3 1 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = n
if n > 1 and a[0] * 2 < a[1]:
    ans -= 1
for i in range(1, n-1):
    if (a[i-1] + a[i]) * 2 < a[i+1]:
        ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = n
for i in range(n-1):
    if a[i] * 2 < a[i+1]:
        ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=sorted(A)
import numpy
C=numpy.cumsum(B)
cnt=1
for i in range(N-1):
  if C[-2-i]*2>=A[-1-i]:
    cnt+=1
  else:
    print(cnt)
    exit()
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
i=list(map(int,input().split()))
i.sort()
temp=1
size=i[0]
for k in range(1,n):
  if size*2>=i[k]:
    temp+=1
    size+=i[k]
  else:
    temp=1
print(temp)

Submission status: Wrong Answer

Solution code:
n=int(input())
i=list(map(int,input().split()))
i.sort()
temp=1
size=i[0]
for k in range(1,n):
  if i[k-1]*2>=i[k]:
    temp+=1
    size+=i[k]
  else:
    temp=1
print(temp)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
flag=0
ans=1
a_cumulative=[0]
for i in range(n):
  flag+=a[i]
  a_cumulative.append(flag)
a.reverse()
a_cumulative.reverse()
for j in range(n-1):
  if a[j]<= a_cumulative[j+1]*2:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
creatures = list(map(int, input().split()))

creatures.sort()
cumsum = [0]
tmp = 0
for c in creatures:
    tmp += c
    cumsum.append(tmp)

count = 0
for i,c in enumerate(creatures):
    index_new = 0
    index_old = i 
    t = cumsum[i+1]
    #print(f'{i=}')
    #print(f'{t=}')
    while True:
        index_new = bisect.bisect_right(creatures,t*2)
        if N == index_new:
            count += 1
            break
        if index_old+1 < index_new:
            t = cumsum[index_new]
            index_old = index_new
        else:
            break

print(count)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)
ans = N
for i in range(N-1):
    if A[i]*2 < A[i+1]:
        A[i+1] += A[i]
        ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)
ans = N
for i in range(N-1):
    if A[i]*2 < A[i+1]:
        ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [ int(x) for x in input().split() ]

a.sort()
t = 0
s = 0
for k, v in enumerate(a):
   s += v
   if k+1 < n and s*2 < a[k+1]:
       t = k+1
       break

print(n-t)

Submission status: Wrong Answer

Solution code:
# わからない

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n = int(input())
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))
ans = 1
for i in range(n-2,-1,-1):
  if acc[i]>=a[i+1]:
    ans += 1
  else:
    break
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
saisho=10**15
cnt=0
for i in range(n):
    if  A[i]<saisho/2:
        saisho=A[i]
    else:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

cnt = 1
for i in range(n - 1):
    if a[i + 1] * 2 >= a[i]:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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

N = int(input().split()[0])
a_list = list(map(int, input().split()))
a_list = list(sorted(a_list))

win_c = 0
total_size = sum(a_list)
max_size_list = []

lose_flag = False
now_size = 0
first_winner = -1
for i, a in enumerate(a_list):
    if i == N - 1:
        # 最後は確実に勝つ
        if lose_flag:
            first_winner = i
        break
    # 確実に倒せるやつはどいつか
    now_size += a
    if now_size * 2 >= a_list[i + 1]:
        # 勝てる
        if lose_flag:
            first_winner = i
            break
    else:
        lose_flag = True
c = N if first_winner == -1 else N - first_winner

ans = c
print(ans)

Submission status: Wrong Answer

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

A.sort()
ans=N
tmp=0
for i in range(N):
    if tmp*2<A[i]:
        ans-=i
    tmp+=A[i]

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
N = int(input())
a = list(map(int, input().split()))
a.sort()

b = list(accumulate(a))

ans = N
for i in range(N-1)[::-1]:
    if 2 * b[i] < a[i+1]:
        ans -= i+1
        
print(ans)

Submission status: Wrong Answer

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

def hoge(num):
    value=sum(A[:num+1])
    for a in A[num+1:]:
        if value*2>=a:
            value+=a
        else:
            return (0)
    return(1)

if hoge(0):
    print(N)
    exit()

st=0
end=N-1
while end-st>1:

    num=(end+st)//2
    print(num)
    if not hoge(num):
        st=num
    else:
        end=num

print(N-st -1)

Submission status: Wrong Answer

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))
# import sys
# input = sys.stdin.readline

import itertools as it

N=one_int()

A=many_int()

A=sorted(A)
sums_A=list(it.accumulate(A))

for i in range(N-2, 0, -1):
    if 2*sums_A[i] < A[i+1]: 
        break

if len(set(A))==1:
    print(N)
else:
    print(N-i-1)

Submission status: Wrong Answer

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))
# import sys
# input = sys.stdin.readline

import itertools as it

N=one_int()

A=many_int()

A=sorted(A)
sums_A=list(it.accumulate(A))

for i in range(N-1):
    if 2*sums_A[i] < A[i+1]: 
        break

if len(set(A))==1:
    print(N)
else:
    print(N-i-1)

Submission status: Wrong Answer

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))
# import sys
# input = sys.stdin.readline

import itertools as it

N=one_int()

A=many_int()

A=sorted(A)
sums_A=list(it.accumulate(A))





for i in range(N-1):
    if 2*sums_A[i] < A[i+1]: 
        break

print(N-i-1)

Submission status: Wrong Answer

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

A.sort()
cnt=1
size=A[0]
for i in range(1,N):
    if A[i]<=2*size and 2*A[i]>=size:
        cnt+=1
    elif A[i]<=2*size and 2*A[i]<size:
        if A[i]==A[i-1]:
            cnt+=1
    elif 2*A[i]>=size and A[i]>2*size:
        cnt=1
    size+=A[i]
print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    A = sorted(A)

    now = N
    A_cumsum = [A[0]]
    for i in range(1,N):
        A_cumsum.append(A_cumsum[-1]+A[i])

    
    for i in range(N):
        if i==N-1:
            break
        if A_cumsum[i]*2>=A[i+1]:
            break
        else:
            pass
    print(N-i)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=n
tmp=0
for i in range(n-1):
    tmp+=a[i]
    if not tmp*2>=a[i+1]:
        ans-=(i+1)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [0]
for i in range(n-1):
    b.append(b[-1]+a[i])

print(b)
result = 1
for i in range(1, n+1):
    if b[-i]*2 < a[-i]:
        break
    result += 1
print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=sorted(list(map(int,input().split())))
count=1
sum=n
now=l[0]
for i in range(1,n):
  if now*2<l[i]:
    sum-=count
    now=now+l[i]
    count=0
  else:
    count+=1
    now+=l[i]
print(sum)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=sorted(list(map(int,input().split())))
count=0
sum=n
now=l[0]
for i in range(1,n):
  if now*2<l[i]:
    sum-=count
    now=now+l[i]
    count=0
  else:
    count+=1
    now+=l[i]
print(sum)

Submission status: Wrong Answer

Solution code:
def solve(n, a):
    from itertools import accumulate
    import sys

    sys.setrecursionlimit(10 ** 7)

    # [l,r)
    def dfs(l, r):
        if l == 0 and r == n:
            return True
        acc = c[r] - c[l]
        if l > 0 and (a[l - 1] <= acc * 2):
            if dfs(l - 1, r):
                return True
        if r < n and (a[r] <= acc * 2):
            if dfs(l, r + 1):
                return True
        return False

    c = (0,) + tuple(accumulate(a))

    res = 0
    for i in range(n):
        if dfs(i, i + 1):
            res += 1
    return res


if __name__ == '__main__':
    n = int(input())
    a = tuple(map(int, input().split()))
    print(solve(n, a))
# 最後のサンプルが合わない

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int,input().split())))
pre = [A[0]]
for i in range(1,N):
  pre.append(pre[i-1] + A[i])

lo,hi = 0,N-2
while lo < hi:
  mid = (lo + hi) // 2
  if pre[mid] >= A[mid+1] / 2:
    hi = mid
  else:
    lo = mid + 1
print(N - lo)

Submission status: Wrong Answer

Solution code:
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
mod=10**9+7
def swap(a,b):
    c=a
    a=b
    b=c
    return a,b
def factorial(x): #階乗計算
    n=1
    for i in range(x):
        n=(n*(i+1))%mod
    return n

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x): #約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x): #素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n=int(input())
    a = list(map(int,input().split()))
    ans=1
    k=0
    a.sort()
    for i in range(n-1):
        k+=a[i]
        if k*2>=a[i+1]:
            print(a[i])
            ans+=1
        else:
            ans=1
    print(ans)

main()

Submission status: Wrong Answer

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

a.sort()
now = 0
ans = 1
for i in range(n-1):
  now += a[i]
  if 2*now >= a[i+1]:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# sortして累積和と元のリストを後ろから比較。
N = int(input())
A = list(map(int, input().split()))
A.sort()
R = [sum(A[:i]) for i in range(N)]

A.sort(reverse=True)
R.sort(reverse=True)

cnt = 0
for i,j in zip(R[0:], A[:-1]):
#  print(i,j)
  if i * 2 >= j:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
# sortして累積和と元のリストを後ろから比較。
N = int(input())
A = list(map(int, input().split()))
A.sort()
R = [sum(A[:i]) for i in range(N)]

A.sort(reverse=True)
R.sort(reverse=True)

cnt = 0
for i,j in zip(R[0:], A[:-1]):
#  print(i,j)
  if i * 2 >= j:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
from itertools import*
n,*a=map(int,open(0).read().split())
acc=list(accumulate(sorted(a)))[::-1]
c=1
i=0
while i<n-1:
  if acc[i]<=acc[i+1]*2:
    c+=1
    i+=1
  else:
    break
print(c)

Submission status: Wrong Answer

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

A.sort()

mi=A[0]
mx=A[0]
cnt=1
for i in range(1,N):
    if A[i]<=mi and mi<=2*A[i]:
        cnt+=1
    elif mi<=A[i] and 2*mi>=A[i]:
        cnt+=1
    elif A[i]<=mx and 2*A[i]>=mx:
        cnt+=1
    elif A[i]>=mx and 2*mx>=A[i]:
        cnt+=1

    a=mi/2+A[i]
    b=mi+A[i]/2
    c=mx/2+A[i]
    d=mx+A[i]/2
    mi=min(a,b,c,d)
    mx=max(a,b,c,d)
print(cnt)

Submission status: Wrong Answer

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

S=[A[0]]
for i in range(1,N):
  S.append(S[i-1]+A[i])
#print(S)

T=[0]*(N-1)
for i in range(N-1):
  if S[i]*2>=S[i+1]:
    T[i]=1
#print(T)

ans=1
for t in T:
  if t==0:
    ans=1
  else:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
#%%
A.sort()
cnt = N
lmin = 0
for ind,i in enumerate(A[:-1]):
    lmin += i
    if(lmin*2<A[ind+1]):
        cnt -= 1
        lmin = 0


print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
cnt = N
for ind,i in enumerate(A[:-1]):
    if(i*2<A[ind+1]):
        cnt -= 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import bisect
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
mx = max(A)
ind = bisect.bisect_left(A,mx//2)
if(A[ind]==mx//2):
    ind-=1
print(N-ind)

Submission status: Wrong Answer

Solution code:
import bisect
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
mx = max(A)
ind = bisect.bisect_left(A,mx//2)
print(N-ind)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
tmp = 0
ans = 1
for i in range(n-1):
  tmp+= a[i]
  if a[i] *2 >=  a[i+1]:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

def accmulate(arr):
    global cs
    N = len(arr)
    cs = [0]*(N+1)
    for i in range(N):
        cs[i+1] = cs[i] + arr[i]

# [l,r)
def query(l,r):
    return cs[r] - cs[l]

A = sorted(A)
accmulate(A)

ans = N

for i in range(N-1):
    if not A[i+1] <= 2*query(0,i+1):
        ans -= (i+1)
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())
A.sort()
t, acc = 0, 0
for i in range(N - 1):
    acc += A[i]
    if acc < A[i + 1]:
        t = i + 1
print(N - t)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=sorted(list(map(int,input().split())))
ls=[]
tmp=0
for i in l:
    tmp+=i
    ls.append(tmp)
l.reverse()
ls.reverse()
l=[0]+l
ans=0
for i in range(n):
    if ls[i]*2>=l[i]:ans+=1
    else:print(ans);exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
creature_list = [ int(v) for v in input().split() ]

def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist
creature_list = sorted(creature_list)
creature_list_0 = list(reversed(creature_list))
creature_list = cumsum(creature_list)
creature_list = list(reversed(creature_list))


for i in range(1,n):
    if creature_list_0[i-1] > creature_list[i] * 2:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
l=0
h=n-1
while l<h:
    t=(l+h)//2
    b=sum(a[:t+1])
    if b*2>=a[-1]:
        h=t
        break
    for i in range(t+1,n):
        if b*2<a[i]:
            l=t+1
            break
        b+=a[i]
    else:
        h=t
print(n-l)

Submission status: Wrong Answer

Solution code:
# 一番でかいやつは他のやつすべてを吸収できる
# -> i番目において自分より低いやつはすべて吸収できる
# なのでソートして考える
# 自分より高いやつらについては、自分より低いやつをすべて吸収した大きさの
# 2倍以下のやつは吸収できるのでまずそれを求め、
# 自分より大きいものについてそれを適用アンド更新していって最後までいけば生き残れる
# 累積和でもっておく

n = int(input())
arr = list(sorted(list(map(int, input().split()))))
temp_arr = [0 for _ in range(n + 1)]
for i in range(n):
    temp_arr[i + 1] = arr[i] + temp_arr[i]
ans = 1  # 最大のやつ
for i in range(n):
    me = temp_arr[i]
    print(i, me)
    j = i
    while j < n-1:
        if arr[j] <= me * 2:
            me += arr[j]
            j += 1
        else:
            break
    if j == n - 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from bisect import bisect

N = int(input())
A = list(map(int, input().split()))
A.sort()
max_a = A[-1]

A_cs = list(accumulate(A))

def can_survive(i): #ソート済みAのi番目(0-index)の生き物が生き残る
  can_absorb = i
  while True:
    cur_volume = A_cs[can_absorb]
    can_absorb_v = A_cs[can_absorb]*2
    if can_absorb_v >= max_a:
      return True
    next_can_absorb = bisect(A,can_absorb_v)-1
    if can_absorb == next_can_absorb:
      return False
    else:
      can_absorb = next_can_absorb

#print([can_survive(i) for i in range(N)])

def search(l,r): #surviveする最小のi
  if r==l+1:
    if can_survive(r):
      return r
    else:
      return l
  c = (l+r)//2
  if can_survive(c):
    return search(l,c)
  else:
    return search(c,r)

x = search(0,N)
print(N-x)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
asum = [0 for _ in range(n+1)]
for i in range(n):
    asum[i+1] = asum[i] + a[i]
lim = [-1 for _ in range(n)]
l = r = 0
while l < n:
    while r < n and a[r] <= a[l] * 2:
        r += 1
    lim[l] = r
    l += 1
ans = 0
for i in range(n):
    if lim[i] == n or a[lim[i]] <= asum[lim[i]] * 2:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
t=sorted(map(int, input().split()),reverse=True)
sm=sum(t)
ans=0
for i in t:
    sm-=i
    ans+=1
    if i>=sm*2:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
a_t = a_t[1:]
ans = 0
canEat = []
mi = 0
for i in range(n):
    index = bisect.bisect_right(a, a[i] * 2) - 1
    canEat.append(index)
    if index == n - 1:
        if not mi:
            mi = i
for i in range(n):
    index = bisect.bisect_right(a, a_t[i] * 2) - 1
    if index >= mi:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
A.sort(key=lambda x:-x)
S=[0]
for i in range(N):
  S.append(S[i-1]+A[i-1])
ans=1
for i in range(1,N):
  if A[i-1]<=2*(S[N]-S[i]):
    ans+=1
  else:
    break
print(ans)

Submission status: Wrong Answer

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

total_size = A[0]
for col,size in enumerate(A[1:]):
    if total_size*2 < size:
        print(N - 1 - col)
        exit()
    total_size += size
print(N)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
a.sort(reverse=True)
b=[0]
for i in a:
    b.append(i+b[-1])
ans=1
for i in range(1,n):
    print(b[i]-b[i-1],(b[-1]-b[i]))
    if b[i]-b[i-1]<=2*(b[-1]-b[i]):
        ans+=1
    else:break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

a = list(map(int, input().split()))
a = sorted(a)

ans = n
size = a[0]
count = 1
for i in range(1, n - 1):
    if a[i + 1] > size * 2:
        ans -= count
        count = 1
        size = a[i + 1]
    else:
        count += 1
        size += a[i + 1]


print(ans)

Submission status: Wrong Answer

Solution code:
f = lambda: map(int,input().split())
n = int(input())
a = sorted(list(f()))
s = [a[0]]
for i in range(n-1):
    s.append(s[-1]+a[i+1])
for i in range(2,n):
    if s[-i]*2<a[-i+1]:
        break
print(i-1)

Submission status: Wrong Answer

Solution code:
n = input()
v = map(int, raw_input().split(' '))
v.sort()

def good(mid, v):
	sum = v[mid]
	for i in range(n):
		if i != mid:
			if i > 2 * sum:
				return False

			sum += i

	return True


l, r = 0, n - 1
best = n - 1

while l <= r:
	mid = (l + r) / 2

	if good(mid, v):
		best = mid
		r = mid - 1
	else:
		l = mid + 1

print n - best

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
sum_a = 0
for i in range(0,N):
	sum_a += a[i]
	if sum_a*2 < a[i]:
		t = i+1

			
print(N-t)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
sum_a = 0
for i in range(0,N-1):
	sum_a += a[i]
	if sum_a*2 < a[i+1]:
		t = i+1
		flag = 0
	if flag == 0:
		break
			
print(N-t)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
i = 0
sa = a[0]
while flag:
	if 2*sa <= a[i+1]:
		sa += a[i]
		t = i
		i += 1
		if i == N-1: 
			flag = 0
	else:
		flag = 0
		
print(N-t)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
i = 0
while flag:
	if a[i]*2 > a[i+1]:
		flag = 0	
	else:
		t = i
		i += 1
		
print(N-t)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
i = 0
while flag:
	if a[i]*2 > a[i+1]:
		t = i
		flag = 0	
	else:
		i += 1
print(N-t)

Submission status: Wrong Answer

Solution code:
n = int(input())
creatures = list(map(int,input().split()))
creatures.sort()
ans = n
p = creatures[0]
r = 1
for i in range(1, n):
    if creatures[i] > p * 2:
        p = creatures[i]
        ans -= r
        r = 0
    else:
        p += creatures[i]
        r += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
creatures = list(map(int,input().split()))
creatures.sort()
ans = 1
p = creatures[0]
for i in range(1, n):
    if creatures[i] > p * 2:
        p = creatures[i]
    else:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
creatures = list(map(int,input().split()))
creatures.sort()
ans = n
for i in range(n-1):
    if creatures[i+1] > creatures[i] * 2:
        ans -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = sorted(list(map(int,input().split())),reverse=True)
B = [sum(A[i:]) for i in range(N)]

min_abs = A[0]
ans = 1
for i in range(1,N):
    if A[i]*2 >= min_abs:
        ans += 1
    elif B[i]*2 >= min_abs:
        ans += 1
    else:
        break
    min_abs = A[i]
    
print(ans,A,B)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
int(input())
a = sorted(map(int, input().split()), reverse=True)
print(sum([1 for i in a if bl(a, 2 * i) != 0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_s = input()
a_s = a_s.split(" ")

creatures = [(i, int(a_s[i])) for i in range(n)]
creatures.sort(key=lambda x:x[1])

print(creatures)

suv = 0

for i in range(n):
    buf = creatures[i][1]
    for j in range(n):
        if i != j:
            if buf * 2 >= creatures[j][1]:
                buf += creatures[j][1]
            else:
                break
    if buf * 2 >= creatures[n-1][1]:
        suv += 1
print(suv)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_s = input()
a_s = a_s.split(" ")

creatures = [(i, int(a_s[i])) for i in range(n)]
creatures.sort(key=lambda x:x[1])

print(creatures)

suv = 0

for i in range(n):
    buf = creatures[i][1]
    for j in range(n):
        if i != j:
            if buf * 2 >= creatures[j][1]:
                buf += creatures[j][1]
    if buf * 2 >= creatures[n-1][1]:
        suv += 1
print(suv)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right

def search(elem, pos):
	return bisect_right(arr, elem*2) == pos + 1


n = input()
arr = map(int, raw_input().split())
arr.sort()

count = 0
for i, j in enumerate(arr):

	if search(j, i):
		count += 1

if count:
	print n - (count - 1)
else:
	print n

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right

def search(elem, pos):
	return bisect_right(arr, elem*2) == pos + 1


n = input()
arr = map(int, raw_input().split())
arr.sort()

count = 0
for i, j in enumerate(arr):

	if search(j, i):
		count += 1

print n - (count - 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split(' ')]

a.sort()
s = [a[0]]
for i in range(1, n):
  s.append(a[i - 1] + a[i])

res = 1
for i in range(1, n):
  if s[-i] * 2 >= a[-i + 1]:
    res += 1
  else:
    break

print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(raw_input())
A = map(lambda x:int(x), raw_input().split())

A.sort()

A = np.asarray(A)
S = np.zeros_like(A)
s=0
for i in range(N):
    s += A[i]
    S[i] = s

#print A[1:]
#print S[:-1]*2
index = np.where(A[1:] - S[:-1]*2 > 0)[0]
if index.shape[0]:
    print N - index[0]-1
else:
    print N

Submission status: Wrong Answer

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

n.sort()
SUM = 0
count = 0
for i in range(len(n)-1):
    SUM += n[i]
    if n[i+1] > SUM*2:
        count += 1
print(len(n)-count)

Submission status: Wrong Answer

Solution code:
import sys
m = int(input())
n = list(map(int,input().split()))

frag = 0
count = 0
while(True):
    if frag == 0:
        for i in range(len(n)-1):
            if n[i]*2 < n[i+1]:
                frag = 1
    if frag == 0:
        print(len(n)-count)
        sys.exit()
    count += 1
    n.sort()
    n[0] += n[1]
    n.remove(n[1])
    n.sort()
    frag2 = 0
    for i in range(len(n)-1):
        if n[i]*2 < n[i+1]:
            frag2 = 1
    if frag2 == 0:
        print(len(n))
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
m = int(input())
n = list(map(int,input().split()))

frag = 0
count = 0
while(True):
    if frag == 0:
        for i in range(len(n)-1):
            if n[i]*2 < n[i+1]:
                frag = 1
    if frag == 0:
        print(len(n)-count)
        sys.exit()
    count += 1
    n.sort()
    n[0] += n[1]
    n.remove(n[1])
    frag2 = 0
    print(n)
    for i in range(len(n)-1):
        if n[i]*2 < n[i+1]:
            frag2 = 1
    if frag2 == 0:
        print(len(n))
        sys.exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from itertools import accumulate


def main():
    # 入力処理
    N = int(input())
    As = sorted([int(x) for x in input().split()])
    print(As, file=sys.stderr)

    # アルゴリズム本体
    Bs = list(accumulate(As))
    print(Bs, file=sys.stderr)

    M = 1
    for A, B in zip(As[1:N], Bs[0:N-1]):
        if A / B > 2:
            break
        else:
            M += 1
    else:
        M = 0

    # 出力
    print(N - M, file=sys.stderr)
    print(N - M)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(raw_input())
count = 0
B = list(map(int,raw_input().split()))
A=np.array(B)
count=0
A=np.sort(A)
for i in range (N):
    print(A)
    j=0
    co=0
    a=A[i]
    for j in range(i):
        a+=A[j]
    j=1
    while(1):
        if i+j>=N:
            count+=1
            break
        if 2*a>=A[i+j]:
            a+=A[i+j]
        else:
            break
        j+=1
            
print(count)

Submission status: Wrong Answer

Solution code:
def gattai(ar,i):
    sm = sum(ar[:i+1])
    idx = i
    while True:
        if idx == len(ar)-1:
            return len(ar)
        elif ar[idx+1] <= sm*2:
            sm += ar[idx+1]
            idx += 1
            continue
        else: return i-idx-1

n = int(input())
ar = list(map(int, input().split()))
ar.sort()

ans = 0
idx = 0
while ans <= 0:
    hoge = gattai(ar, idx)
    ans += hoge
    idx = abs(ans) + 1

print(ans)

Submission status: Wrong Answer

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

a.sort()

left = 0
right = N

center = (left+right)//2

def check(i):
	s = sum(a[:i+1])
	now = s
	# print("now",a[:i+1])
	for j in range(i, N-1):
		# print("vs",now,a[j+1])
		if now*2 < a[j+1]:
			return(False)
		now += a[j+1]
	# print("now",s)
	return(True)

while right - left > 1:
	center = (left+right)//2
	# print("check",a[center],center)
	if check(center):
		right = center
		# print("able")
	else:
		left = center
		# print("not")

if check(center):
	center-=1

print(N-(center+1))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())

C = list(map(int, input().split()))

C.sort(reverse=True)

color = 0
size  = -1
comp  = 0
for i in range(0, N):
    # C[i] can eat the bigger one
    if C[i] >= size / 2:
        color += 1
        size = C[i]
        continue
    # need to eat some
    else:
        comp += C[i]

    # some composite creature can eat it
    if comp >= size/2:
        color += 1
        size = comp
        comp = 0
print(color)

Submission status: Wrong Answer

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

a.sort()

left = 0
right = N

center = (left+right)//2

def check(i):
	s = sum(a[:i+1])
	now = s
	# print("now",a[:i+1])
	for j in range(i, N-1):
		# print("vs",now,a[j+1])
		if now*2 < a[j+1]:
			return(False)
		now += a[j+1]
	# print("now",s)
	return(True)

while right - left > 1:
	center = (left+right)//2
	# print("check",a[center])
	if check(center):
		right = center
		# print("able")
	else:
		left = center
		# print("not")
	
if check(0):
	center -= 1

print(N-center)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left

n=int(raw_input())
a=map(int,raw_input().split())
sa=sorted(a)
s=[0]*n
s[0]=sa[0]
for i in xrange(n-1):
    s[i+1]+=s[i]+sa[i+1]
idx=bisect_left(sa,(sa[n-1]+1)/2)
idx1=bisect_left(s,(sa[idx]+1)/2)
print n-idx1