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

Solution (Python):
import bisect
import math

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

a.sort()

n1 = math.ceil(math.log(1000000000,2))+1

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

ans = 0
for i in range(n) :
  h = 0
  m = a[i]*2
  for j in range(n1) :
    mg = bisect.bisect_left(a,m)
    if mg <= n-1 and m == a[mg] :
      mg += 1
    m = s[mg-1]*2
    if m >= a[n-1] :
      ans += 1
      break
  
print(ans)

Solution (Python):
from itertools import accumulate
from bisect import bisect_left as bl
def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    ans = N
    tmp = 0
    B = list(accumulate(A))
    for i,b in enumerate(B):
        k = bl(A,b*2)
        if k == N:continue
        if A[k-1] == A[i] and A[k] > 2*b:
            tmp = i+1
    ans -= tmp
    
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
from itertools import accumulate


def main():
    creatures = int(input())
    size = [int(x) for x in input().split()]
    size.sort()
    accumulate_size = list(accumulate(size))
    survivable = 0
    for i in range(creatures - 1):
        if 2 * accumulate_size[i] < size[i + 1]:
            survivable = i + 1
    print(creatures - survivable)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=1
s=sum(a)-a[-1]
for i in range(n-1):
  if 2*s>=a[n-i-1]:
    ans+=1
    s-=a[n-i-2]
  else:
    break
print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
S = [0] * N
total = 0
for i in range(N):
    total += A[i]
    S[i] = total
S = [0] + S
for i in range(1, N + 1):
    if A[-i] > 2 * S[-i - 1]:
        print(i)
        break

Solution (Python):
N = list(map(int,input().split()))
A = [(a,idx+1) for idx,a in enumerate(list(map(int,input().split())))]
A = sorted(A)

color_set = set()
prev_sum = 0
prev_num = 0
for a,color in A:
  if prev_num == a or prev_sum*2 >=a :
    color_set |= {color}
  else:
    color_set = {color}
  prev_sum += a
  prev_num = a
  
print(len(color_set))

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

tmp = 0
sum_a = sum(A)
ind = N+1
for i in range(N-1):
    tmp += A[i]*2
    if tmp < A[i+1]:
        ind = i

if ind == N+1:
    print(N)
else:
    print(N-ind-1)

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

tmp = 0
sum_a = sum(A)
ind = N+1
for i in range(N-1):
    tmp += A[i]*2
    if tmp < A[i+1]:
        ind = i

if ind == N+1:
    print(N)
else:
    print(N-ind-1)

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

tmp = 0
sum_a = sum(A)
ind = N+1
for i in range(N-1):
    tmp += A[i]*2
    if tmp < A[i+1]:
        ind = i

if ind == N+1:
    print(N)
else:
    print(N-ind-1)

Solution (Python):
n = int(input())
a = sorted(map(int, input().split()))

acc = 0
ans = 0

for i in range(n):
    if acc * 2 >= a[i]:
        ans += 1
    else:
        ans = 1
    acc += a[i]

print(ans)

Solution (Python):
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] * 2 >= a[i+1]:
        ans += 1
    else:
        break

print(ans)

Solution (Python):
n=int(input())
a=sorted(list(map(int,input().split())))
now=a[0]
ans=1
for i in range(1,n):
    if now*2>=a[i]:
        ans+=1
    else:
        ans=1
    now+=a[i]
print(ans)

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1
m = A[0]
for i in range(n-1):
    if A[i+1] <= 2*m:
        ans += 1
    else:
        ans = 1
    m += A[i+1]
print(ans)

Solution (Python):
from itertools import accumulate

N = int(input())
A = [int(i) for i in input().split()]
A.sort()
Acum = list(accumulate(A))

cnt = [1] * N
for i in range(N-1):
    
    if A[i+1] <= Acum[i] * 2:
        cnt[i+1] += cnt[i]

print(cnt[-1])

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = sorted(inpl())
b = [0]
for i in a:
    b.append(b[-1]+i)
res = 0
for i in reversed(range(n)):
    if i == n-1: 
        res += 1
        continue
    if (a[i] + b[i])*2 < a[i+1]:
        break
    res += 1
print(res)

Solution (Python):
from bisect import bisect_right
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    b = [v for v in a]
    for i in range(1, n):
        b[i] += b[i-1]
    ans = 0
    for i in range(n):
        target = b[i]
        index = bisect_right(a, 2*target)
        while index < n:
            target = b[index-1]
            j = index-1
            index = bisect_right(a, 2*target)
            if j+1 == index:
                break
        if index == n:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
a=sorted(list(map(int,input().split())))
b=[0]*n
b[0]=a[0]
for i in range(1,n):
  b[i]=b[i-1]+a[i]
p=1
for i in range(n-1)[::-1]:
  if b[i]*2>=a[i+1]:
    p+=1
  else:
    break
print(p)

Solution (Python):
n, *a = map(int, open(0).read().split())
a = [0] + sorted(a) + [1e9+1]

l, r = 0, n+2
while r-l>1:
        mid = (l+r)//2
        m = a[mid]
        for i in range(n+1):
                if i==mid: continue
                if a[i]<=m*2: m += a[i]
                else: break
        else:
                r = mid
                continue
        l = mid
print(n-l)

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

cums.pop(0)

ans = 1
for i in range(N-2,-1,-1):
    if A[i+1] <= 2*cums[i]:
        
        ans += 1
    else:
        print(ans)
        exit()
print(ans)

Solution (Python):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=int)
A.sort()

B = np.cumsum(A)

ans = 0
for i in range(N - 1):
    if B[i] * 2 >= A[i + 1]:
        ans += 1
    else:
        ans = 0

ans += 1
print(ans)

Solution (Python):
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort()
    cur = 0
    ans = 0
    for i in range(N):
        cur += A[i]
        ans += 1
        if i == N-1:
            break
        if A[i+1] <= cur*2:
            continue
        else:
            ans = 0
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):


n = int(input().rstrip())

monsters = list(reversed(sorted(map(int, input().rstrip().split(" ")))))

cnt = [0 for i in range(n)]
cnt[n - 1] = monsters[n - 1]
for i in reversed(range(n - 1)):
    cnt[i] = cnt[i + 1] + monsters[i]

dic = {}


def can_alife(idx: int):
    if idx == 0:
        return True
    if idx in dic:
        return dic[idx]

    ret = False
    if monsters[idx - 1] <= cnt[idx] * 2:
        ret = can_alife(idx - 1)
    dic[idx] = ret
    return ret


ans = len([i for i in range(n) if can_alife(i)])
print(ans)

Solution (Python):
import sys
from operator import itemgetter
from itertools import accumulate
def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    C = list(accumulate(A))
    dp = [0] * N
    for i in range(N-1):
        if C[i] * 2 >= A[i+1]:
            dp[i+1] = dp[i] + 1
    print(dp[N-1]+1)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()

from itertools import accumulate

Acum = list(accumulate(A))

cnt = [1] * N
for i in range(N-1):
    if Acum[i] * 2 >= A[i+1]:
        cnt[i+1] += cnt[i]

print(cnt[-1])

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
imos=[a for a in A]
for i in range(N-1):
    imos[i+1]+=imos[i]


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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
a.sort()
cs = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]

res = 0
for i in range(1, N):
  if cs[i] * 2 >= a[i]: res += 1
  else: res = 0
print(res + 1)

Solution (Python):
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>=B[-1-i]:
    cnt+=1
  else:
    print(cnt)
    exit()
print(cnt)

Solution (Python):
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
    size+=i[k]
print(temp)

Solution (Python):
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
  else:
    break
print(ans)

Solution (Python):

from itertools import accumulate
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[0]+a
b=list(accumulate(a))


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

Solution (Python):
N,*A=map(int, open(0).read().split())
A=sorted(A)
ans=1
acc=0
for a in A:
    if a>acc*2:
        ans=1
    else:
        ans+=1
    acc+=a
print(ans)

Solution (Python):
n = int(input())
A = list(map(int,input().split()))

A = sorted(A)

acum = [0]*(n+1)
for i in range(n):
  acum[i+1]=acum[i]+A[i]
  
for i in range(n):
  if acum[-i-2]*2 < A[-i-1]:
    break
    
print(i+1)

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

s = sum(a)
for i, v in enumerate(a):
    s -= v
    if s*2 < v:
        print(i+1)
        break

Solution (Python):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    A = read_list()
    A.sort()
    s = 0
    res = 0
    for a in A:
        if s != 0 and s * 2 < a:
            res = 0
        s += a
        res += 1

    print(res)

        
if __name__ == "__main__":
    main()

Solution (Python):
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]
    
    
    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-1
        else:
            break

print(count)

Solution (Python):
n = int(input())
A = sorted(list(map(int, input().split())))

ans = n
cnt = A[0]

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

print(ans)

Solution (Python):

N = int(input())
A = list(map(int, input().split()))
A.sort()
tmp = 0
s = 0
for i in range(N-1):
    s += A[i]
    if 2*s < A[i+1]:
        tmp = i+1
print(N - tmp)

Solution (Python):
n = int(input())
a = sorted(map(int, input().split()))

count = 0
s = a[0]
for i in a[1:]:
    if s * 2 >= i:
        count += 1
    else:
        count = 0
    s += i
else:
    count += 1
    
print(count)

Solution (Python):
from itertools import accumulate
N = int(input())
A = sorted(list(map(int,input().split())))
aa = list(accumulate(A))
aa.reverse()
ans = 1
for i in range(N-1):
    if 3*aa[i+1] >= aa[i]:
        ans += 1
    else:
        break
print(ans)

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

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

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

ok=n-1
ng=-1

while abs(ok-ng)>1:
 mid=(ok+ng)//2

 inx=mid
 bool=True
 sum_mid=sum(a[:mid+1])

 while bool and inx!=n-2:
  if sum_mid*2>=a[inx+1]:
   sum_mid+=a[inx+1]
   inx+=1
  else:
   bool=False

 if bool:
  ok=mid
 else:
  ng=mid

print(n-ok)

Solution (Python):
n=int(input())
A=sorted(list(map(int,input().split())))

for i in range(1,n):
    A[i]=A[i]+A[i-1]

cnt=1
for i in reversed(range(1,n)):
    if A[i]<=A[i-1]*3:
        cnt +=1
    else:break

print(cnt)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
s = []
t = 0
for i in range(n-1):
    t += a[i] 
    s.append(t)
y = 1
for i in range(n-1, 0, -1):
    if s[i-1]*2 >= a[i]:
        y += 1
    else: break
print(y)

Solution (Python):
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

print(n-t)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans=0
size=0
for i in range(len(a)):
    if a[i] <= 2*size:
        ans+=1
    else:
        ans=1
    size+=a[i]
print(ans)

Solution (Python):
from sys import stdin
from itertools import accumulate
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()
lin = list(accumulate(li))
point = 1
for i in range(n-1):
    if lin[i]*2 >= li[i+1]:
        point += 1
    else:
        point = 1
print(point)

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

A.sort()

work = 0
lastindex = 0
for i in range(N-1):
  work += A[i]
  if work * 2 >= A[i+1]:
    if lastindex == -1:
      lastindex = i
  else:
    lastindex = -1
    
if lastindex == -1:
  print(1)
else:
  print(N-lastindex)

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

a.sort()


ans = 0
cnt = 0

for i in range(0,N):
    if a[i] <= cnt*2:
        ans += 1
        cnt += a[i]

    else:
        ans = 0
        cnt += a[i]
ans += 1

print(ans)

Solution (Python):
import numpy as np
n = int(input())
lst = sorted(list(map(int,input().split())))

res = np.cumsum(lst).tolist()
cnt = 0
for i in range(n-1):
    x = res[i]
    if lst[i+1] <= x*2:
        cnt += 1
    else:
        cnt = 0
print(cnt+1)

Solution (Python):
def cumulative_sum(l):
    cumu = [0]
    s = 0
    for num in l:
        s += num
        cumu.append(s)
    return cumu

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

A.sort()

C = cumulative_sum(A)

AM = [C[i+1] for i in range(N)]

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

Solution (Python):
def cumulative_sum(l):
    cumu = [0]
    s = 0
    for num in l:
        s += num
        cumu.append(s)
    return cumu

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

A.sort()

C = cumulative_sum(A)

AM = [C[i+1] for i in range(N)]

k = 1
for i in range(N):
    AM[i] = max(AM[i],AM[max(0,i-1)])
    for j in range(max(k,i+1),N):
        if AM[i]*2 >= A[j]:
            AM[i] += A[j]
            k = j+1
        else:
            break

S = sum(A)
ans = 0
for i in range(N):
    if AM[i] == S:
        ans += 1
print(ans)

Solution (Python):
n = int(input())
lst1 = list(map(int,input().split()))
lst1.sort()
for i in range(1,n):
    lst1[i] += lst1[i-1]



for i in range(n-1,0,-1):
    if lst1[i]-lst1[i-1] > lst1[i-1]*2:
        print(n-i)
        exit()

print(n)

Solution (Python):
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]*2>=a[i+1]:
    ans += 1
  else:
    break
print(ans)

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
A.sort()
cnt=1
cum=0
for i in range(n-1):
    cum+=A[i]
    if A[i+1]-2*cum<=0:
        cnt+=1
    else:
        cnt=1
print(cnt)

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

su=sum(A)
cnt=1
for i in range(N-1,0,-1):
    if (su-A[i])*2<A[i]:
        break
    else:
        cnt+=1
        su=su-A[i]

print(cnt)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
csize = 0
ans = 0

for i in range(n):
    ans += 1
    if csize*2 < a[i]:
        ans = 1
    csize += a[i]

print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort()
rui = [0] * (N + 1)
for i in range(1, N + 1):
    rui[i] = rui[i - 1] + a[i - 1]

cnt = 1
for i in reversed(range(1, N)):
    if 2 * (rui[i]) >= a[i]:
        cnt += 1
    else:
        break

print(cnt)

Solution (Python):
n = int(input())
a = [0] + sorted(list(map(int, input().split())))

j = 0
now = 0
for i in range(n):
    now += a[i]
    if now * 2 < a[i + 1]:
        j = i
print(n - j)

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


sums=0
least=0
for i in range(N):
  if A[i]>sums*2:
    least=i
  sums+=A[i]
print(N-least)

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

A.sort()
sum_A = [0]

for a in A:
    sum_A.append(sum_A[-1] + a)

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

ans = 1
for i, s in enumerate(sum_A):
    if i == 0:
        continue
    if A[i-1] <= s * 2:
        ans += 1
    else:
        break

print(ans)

Solution (Python):
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
li = [0]
for num in lis:
    li.append(li[-1]+num)
def slime(x):
    for i in range(x,n):
        if li[i] * 2 < lis[i]:
            return False
    return True

low = 0
high = n
while high > low+1:
    mid = (high + low) // 2
    if slime(mid):
        high = mid
    else:
        low = mid
print(n-low)

Solution (Python):
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
li = [0]
for num in lis:
    li.append(li[-1]+num)
def slime(x):
    for i in range(x,n):
        if li[i] * 2 < lis[i]:
            return False
    return True

low = 0
high = n
while high > low+1:
    mid = (high + low) // 2
    if slime(mid):
        high = mid
    else:
        low = mid
print(n-low)

Solution (Python):


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
winner = -1




for i, a in enumerate(a_list):
    if i == N - 1:
        
        if winner == -1:
            winner = i
        break

    now_size += a
    if now_size * 2 >= a_list[i + 1]:
        
        if winner == -1:
            winner = i
    else:
        winner = -1
c = N - winner

ans = c
print(ans)

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

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

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans, suma = 1, 0
for i in range(N-1):
    suma += A[i]
    ans += 1
    if suma * 2 < A[i+1]:
        ans = 1
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
cumA = [0]
for i in range(N):
    cumA.append(cumA[-1] + A[i])
ans = 0
if A[0] * 2 >= A[1]:
    ans += 1
for i in range(N-1):
    if cumA[i+1] * 2 >= A[i+1]:
        ans += 1
    else:
        ans = 1
print(ans)

Solution (Python):
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
        break
        
print(ans)

Solution (Python):
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
    
    if not hoge(num):
        st=num
    else:
        end=num

print(N-st -1)

Solution (Python):
N = int(input())
A = sorted([int(a) for a in input().split()])[::-1]
s = sum(A)
ans = 1
for a in A:
    s -= a
    if a <= s * 2: ans += 1
    else: break
print(ans)

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

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

Solution (Python):
N = int(input())
A = sorted(list(map(int,input().split())))
B = [0 for _ in range(N+1)]
for i in range(N):
    B[i+1] = B[i]+A[i]
cnt = 1
for i in range(N-2,-1,-1):
    if 2*B[i+1]>=A[i+1]:
        cnt += 1
    else:
        break
print(cnt)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
l, r = -1, n
while r - l > 1:
    m = (l + r) // 2
    t = a[m]
    for i in range(n):
        if m == i:
            continue
        if t * 2 >= a[i]:
            t += a[i]
        else:
            break
    else:
        r = m
        continue
    l = m
print(n - r)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[a[0]]
for i in range(1,n):b+=[b[-1]+a[i]]
j=0
while a[-1-j]<=b[-2-j]*2:
  j+=1
  if j+1==n:break
print(j+1)

Solution (Python):
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 itertools as it

N=one_int()

A=many_int()

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

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

print(N-i)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
strength = [0] * (n + 1)
for i in range(1, n):
    strength[i] = strength[i - 1] + a[i - 1]
for i in range(len(a) - 1, -1, -1):
    if strength[i] * 2 < a[i]:
        break
    ans += 1
print(ans)

Solution (Python):
import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
a_sum = 0
k = 0
for i in range(n-1):
    a_sum += a[i]
    if a_sum*2 < a[i+1]:
        k = i+1
    else:
        continue
print(n-k)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=n
sum_former=sum(a)
for i in range(n-1,-1,-1):
    sum_former-=a[i]
    if(2*sum_former < a[i]):
        ans=n-i
        break

print(ans)

Solution (Python):
from bisect import bisect_left
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
cs = [A[0]]
ans = 1
for a in A[1:]:
    cs.append(cs[-1]+a)
for i in range(N-2, -1, -1):
    if cs[i]*2 >= A[i+1]:
        ans += 1
    else:
        break
print(ans)

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

color = [1] * n
for i in range(n):
    if i == 0:
        continue
    if a[i - 1] * 2 >= a[i]:
        color[i] += color[i - 1]
    a[i] += a[i - 1]

print(color[-1])

Solution (Python):
import sys
from itertools import accumulate
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort()
s_ls = [i for i in accumulate(a_ls)]
cnt = 1
for i in range(n-2, -1, -1):
    if s_ls[i] * 2 >= a_ls[i+1]:
        cnt += 1
    else:
        break
print(cnt)

Solution (Python):
import itertools as it

N=int(input())
A=list(map(int,input().split()))
A.sort()
B=list(it.accumulate(A))
cB=[B[i]*2>=A[i+1] for i in range(len(A)-1)]

ans=1
i=N-2
while i>=0 and cB[i]:
    ans+=1
    i-=1

print(ans)

Solution (Python):
from itertools import accumulate
n = int(input())
a = list(map(int,input().split()))
a.sort()
ac = list(accumulate(a))
a.reverse()
ac.reverse()
p = [0] * n
p[0] = 1
for i in range(1,n):
  if a[i-1] <= ac[i] * 2:
    p[i] = p[i-1]
print(sum(p))

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

cnt = 1
tmp = A[0]
for i in range(1, N):
    if tmp * 2 >= A[i]:
        tmp += A[i]
        cnt += 1
    else:
        tmp += A[i]
        cnt = 1
print(cnt)

Solution (Python):
from itertools import accumulate

N = int(input())
A = sorted(list(map(int,input().split())))
acmA = list(accumulate(A))
ans = 1
for i in range(N-2,-1,-1):
  if acmA[i]*2>=A[i+1]: ans += 1
  else:break
print(ans)

Solution (Python):
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])
    ans = 0
    for i in range(1,N):
        if A_cumsum[i-1]*2>=A[i]:
            pass
        else:
            ans = i
    print(N-ans)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]

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

for i in range(N - 2, -1, -1) :
    if A[i] > S[i - 1] * 2 :
        break
        
print(N - i)

Solution (Python):
from itertools import accumulate
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
B=list(accumulate(A))
c=0
for i in range(N-1):
    
    if 2*B[i] >= A[i+1]:
        c+=1
    else:
        c=0
print(c+1)

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

A=sorted(A)

t=A[0]
f=1
for i in range(1,N):
    if(t*2<A[i]):
        f=1
    else:
        f+=1
    t+=A[i]

print(f)

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))
now = a[0]
ans = n
for k,v in enumerate(a[1:]):
  if now * 2 < v:
    ans = n - k - 1
  now += v
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from itertools import accumulate

def main():
    n = int(input().strip())
    v = list(map(int, input().strip().split()))
    v.sort()
    s = [0] + list(accumulate(v))
    ans = 0
    for i in range(1, n):
        if 2 * s[i] >= v[i]:
            ans += 1
        else:
            ans = 0
    ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import itertools
import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()
acc = list(itertools.accumulate(a))
ans = 0
for i in range(n):
    index = bisect.bisect_right(a, acc[i]* 2)
    
    if index <= i + 1 and index < n:
        ans = i+1
print(n - ans)

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

A.sort()

B = [0 for _ in range(N)]
b = 0
for i in range(N):
    b += A[i]
    B[i] = b

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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
a.sort()
cs = [0] * (N + 1)
for i in range(N):
  cs[i + 1] = cs[i] + a[i]
def check(x):
  t = cs[x + 1]
  for i in range(x + 1, N):
    if a[i] <= 2 * t:
      t += a[i]
    else: return False
  return True
ok = N - 1
ng = -1
m = 0
while ok - ng > 1:
  m = (ok + ng) // 2
  if check(m):
    ok = m
  else:
    ng = m
print(N - ok)

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

A.sort()

B = [0 for _ in range(N)]
b = 0
for i in range(N):
    b += A[i]
    B[i] = b

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
a.sort()
l = [0] * N

for i in range(N):
  l[i] = l[i-1] + a[i]

ans = 1
i = N-1
while i > 0 and 2 * l[i-1] >= a[i]:
  ans += 1
  i -= 1

print(ans)

Solution (Python):


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split( )))
a.sort()
a_sm =[]
sm = 0
for i in range(n):
    sm += a[i]
    a_sm.append(sm)
mn = 0
tmp = a[0]
for i in range(1,n):
    if tmp*2 >= a[i]:
        tmp+=a[i]
    else:
        tmp = a_sm[i]
        mn = i
print(n-mn)

Solution (Python):
N = int(input())
A = sorted(list(map(int, input().split())))
t = 0
cumulative_sum = 0
for i in range(N-1):
    cumulative_sum += A[i]
    if A[i+1] > cumulative_sum*2:
        t = i+1
print(N - t)

Solution (Python):
n=int(input())
A=sorted(list(map(int,input().split())))
sum_A=sum(A)
cnt=1
for i in reversed(range(n)):
    sum_A -=A[i]
    if sum_A*2>=A[i]:
        cnt +=1
    else:break
print(cnt)

Solution (Python):
import copy
n=int(input())
A=sorted(list(map(int,input().split())))
B=copy.deepcopy(A)
for i in range(1,n):
    B[i]=B[i]+B[i-1]

cnt=1
for i in reversed(range(n-1)):
    if B[i]*2>=A[i+1]:
        cnt +=1
    else:break
print(cnt)

Solution (Python):


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


B = [0 for _ in range(N)]
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i-1] + A[i]

B.reverse()
A.reverse()








i = 1
while i < N:
    if A[i-1] > B[i] * 2:
        break
    i += 1

print(i)

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

lsum = 0
cnt = 0
for i in range(N-1):
    if (A[i] + lsum) * 2 >= A[i+1]:
        cnt += 1
    else:
        cnt = 0
    lsum += A[i]

print(cnt+1)

Solution (Python):

import sys
import itertools



def main():
    n, *a = map(int, sys.stdin.read().split())
    a.sort()
    
    b = list(itertools.accumulate(a))

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

if __name__ == '__main__':
    main()

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

Solution (Python):
from itertools import accumulate

n = int(input())
a = tuple(sorted(map(int, input().split())))

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

ng = 0
for idx, (acc_, a_) in enumerate(zip(acc, a)):
    if a_ > acc_ * 2:
        ng = idx  
print(n - ng)

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

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

def isOk(n):
    now = sum(A[:n + 1])
    for a in A[n + 1:]:
        if a <= now * 2:
            now += a
        else:
            return False
    return True

ok = N - 1
ng = -1

while ok - ng > 1:
    mid = (ok + ng) // 2

    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(N - (ng + 1))