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 itertools
n = int(input())
a = list(map(int,input().split()))
a.sort()

A = list(itertools.accumulate(a))

cnt = 0
for i in range(n-1):
  s = A[i]
  
  if s*2 < a[i+1] :
    cnt = i+1

print(n-cnt)

Solution (Python):
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])
result = 1
for i in range(1, n+1):
    if b[-i]*2 < a[-i]:
        break
    result += 1
print(result)

Solution (Python):
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=1
  else:
    count+=1
    now+=l[i]
print(sum)

Solution (Python):
from itertools import accumulate


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

    A.sort()
    a = list(accumulate(A))
    answer = N

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

    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import accumulate


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

    A.sort()
    a = list(accumulate(A))
    answer = N

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

    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import accumulate

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

A.sort()
a = list(accumulate(A))
answer = N

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

print(answer)

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

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

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

Solution (Python):

def solve(n, a):
    a.sort()

    res = 0
    sum_ = 0
    for i in range(n):
        if sum_ * 2 < a[i]:
            res = 0
            
            
        sum_ += a[i]
        res += 1
    return res


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    print(solve(n, a))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
sumA = sum(A)-A[N-1]
memo = 0

for i in range(N-1,-1,-1):
  if sumA*2<A[i] or i==0:
    memo = i
    break
  sumA -= A[i-1]
print(N-memo)

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

Solution (Python):
import numpy as np

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

A.sort()
answer = 1
B = A.cumsum()
C = A[1:] <= (2 * B)[:-1]
C = reversed(list(C))
for c in C:
    if not c:
        break
    else:
        answer += 1
print(answer)

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

can = [False for x in range(N-1)] + [True]
for i in range(N-2,-1,-1):
  if pre[i] >= A[i+1] / 2 and can[i+1]:
    can[i] = True
print(can.count(True))

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

Solution (Python):





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():
    
    
    
    
    
    
    
    
    
    
    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]:
            ans+=1
        else:
            ans=1
    print(ans)

main()

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

print(n-cnt)

Solution (Python):

N = int(input())

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

A.sort()


s = 0
ans = 0

for i in range(N):

    if s * 2 >= A[i]:
        ans += 1

    else:
        ans = 1

    s += A[i]

print (ans)

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

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

A.sort()
a = A[0]
result = 1
for i in range(1, N):
    if a * 2 >= A[i]:
        result += 1
    else:
        result = 1
    a += A[i]
print(result)

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

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

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

print(n-t-1)

Solution (Python):

N = int(input())
A = list(map(int, input().split()))
A.sort()
R = []
s = 0
for i in A:
  s += i
  R.append(s)
  


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



cnt = 1
for i,j in zip(R[1:], A[:-1]):

  if i * 2 >= j:
    cnt += 1
  else:
    break
print(cnt)

Solution (Python):
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)
sums=0
uselist=[0]*(n+1)
for i in range(n):
    sums+=lists[i]
    uselist[i]=sums
uselist[n]=0

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

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

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
chk=0
d=[]
for i in range(n):
    d.append(chk+a[i])
    chk=d[-1]
ans=1
for i in range(n-2,-1,-1):
    if d[i]*2>=a[i+1]:
        ans+=1
    else:
        break

print(ans)

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

def cumsum(s):
    n = len(s)
    cs = [0] * (n+1)
    for i in range(n):
        cs[i+1] = cs[i] + s[i]
    return cs

a.sort()
acum = cumsum(a)
ans = 1

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

print(ans)

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
A.sort()
ans = 0
cnt = 1
ikimono = A[0]
for i in range(1,N):
    if ikimono*2 < A[i]:
        ans += cnt
        cnt = 1
        ikimono += A[i]
    else:
        cnt += 1
        ikimono += A[i]
print(N-ans)

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

Solution (Python):
import sys
input=sys.stdin.readline




def check(mid, A):
    x = A[mid]

    
    for i in range(mid):
        x += A[i]

    
    for i in range(mid+1, len(A)):
        if A[i] <= x*2:
            x += A[i]
        else:
            return False
    return True

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.append(0) 
    A.sort()

    lb,ub = 0,N
    while ub - lb > 1:
        mid = (lb + ub)//2
        if check(mid, A):
            ub = mid
        else:
            lb = mid
    
    print(N-lb)

if __name__ == '__main__':
    main()

Solution (Python):


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

l=[A[0]]
for i in range(len(A)-1):
    l.append(l[-1]+A[i+1])
    if (l[-1]-l[-2])>2*l[-2]:
        ans=0
    else:
        ans+=1

print(ans+1)

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

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

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

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

s = 0
point = -1

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

ans = N - point - 1
print(ans)

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

ans=0
sum=0

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

Solution (Python):
N = int(input())
A = sorted([int(_) for _ in input().split()])
summed = [0] * N
summed[0] = A[0]
for n in range(1, N):
    summed[n] = summed[n - 1] + A[n]

impossible = 0
for n in range(1, N):
    if summed[n - 1] * 2 < A[n]:
        impossible = n
print(N - impossible)

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


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


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

Solution (Python):

def main():
    N, *A = map(int, open(0).read().split())
    A.sort()
    total, ng = 0, 0
    
    for i, a in enumerate(A):
        if a > total * 2:
            ng = i
        total += a
    ans = N - ng
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


import sys
from bisect import bisect_right

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            
            ok = mid
        else:
            
            ng = mid
    return ok

N = INT()
A = LIST()
A.sort()


def calc(m):
    
    if m == -1:
        return False
    
    a = sum(A[:m+1])
    
    idx = bisect_right(A, a*2)
    a += sum(A[m+1:idx])
    
    for i in range(idx, N):
        b = A[i]
        if a*2 >= b:
            a += b
        else:
            
            return False
    
    return True

print(N-bisearch_min(-1, N-1, calc))

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            
            ok = mid
        else:
            
            ng = mid
    return ok

N = INT()
A = LIST()
A.sort()


def calc(m):
    
    if m == -1:
        return False
    
    a = sum(A[:m+1])
    
    for i in range(m+1, N):
        b = A[i]
        
        if a*2 >= b:
            a += b
        else:
            
            return False
    
    return True

print(N-bisearch_min(-1, N-1, calc))

Solution (Python):


import sys
from bisect import bisect_right

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            
            ok = mid
        else:
            
            ng = mid
    return ok

N = INT()
A = LIST()
A.sort()


def calc(m):
    if m == -1:
        return False
    a = A[m]
    a += sum(A[:m])
    
    idx = bisect_right(A, a*2)
    a += sum(A[m+1:idx])
    
    for i in range(idx, N):
        b = A[i]
        if a*2 >= b:
            a += b
        else:
            return False
    
    return True

print(N-bisearch_min(-1, N-1, calc))

Solution (Python):
from sys import stdin, exit
N = int(stdin.readline().rstrip())
A = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
sum_A = sum(A)
ans = 1
for a in A:
    sum_A -= a
    if a > sum_A * 2:
        break
    ans += 1
print(ans)

Solution (Python):
N = int(input())
A = sorted(list(map(int,input().split())))
Min = 0
sum = 0
for left in range(N-1):
  sum += A[left]
  if sum * 2 < A[left+1]:
    Min = left + 1
print(N-Min)

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

print(ans)

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

B=[0]*n
B[0]=A[0]

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

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

print(cnt+1)

Solution (Python):
import heapq
N = int(input())
A = [[int(a),1] for a in input().split()]

heapq.heapify(A)
cur1 = heapq.heappop(A)

while A:
  cur2 = heapq.heappop(A)
  if cur2[0] <= cur1[0]*2:
    heapq.heappush(A,[cur1[0]+cur2[0],cur1[1]+cur2[1]])
  else:
    heapq.heappush(A,[cur1[0]+cur2[0],cur2[1]])
  cur1 = heapq.heappop(A)
print(cur1[1])

Solution (Python):
N = int(input())
As = list(map(int, input().split()))
As.sort()
r = 1
s = sum(As)
for i in reversed(range(N)):
  s -= As[i]
  if As[i] <= 2*s:
    r += 1
  else:
    break
print(r)

Solution (Python):
n=int(input())
a=[int(j) for j in input().split()]
a.sort()

tmp=0
ans=n
c=1
for i in range(n-1):
    tmp+=a[i]
    if tmp*2<a[i+1]:
        ans-=c
        c=1
    else:
        c+=1
print(ans)

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
	N = int(input())
	a = list(map(int,input().split()))
	a.sort(reverse=True)
	sum_list = [a[0]]
	for i in range(N-1):
		sum_list.append(sum_list[i]+a[i+1])
	count = 1
	A = sum(a)
	for i in range(N):
		if (A-sum_list[i])*2 >= a[i]:
			count += 1
		else:
			break

	print(count)

if __name__ == "__main__":
	main()

Solution (Python):
import sys
input = sys.stdin.readline
def main():
	N = int(input())
	a = list(map(int,input().split()))
	a.sort()
	sum_list = [a[0]]
	for i in range(N-1):
		sum_list.append(sum_list[i]+a[i+1])
	count = 0
	for i in range(N-1):
		if 2*sum_list[i] < a[i+1]:
			count = i+1

	print(N-count)

if __name__ == "__main__":
	main()

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

A.sort()
a = 0
failed = 0
for i in range(N - 1):
    a += A[i]
    if A[i + 1] > 2 * a:
        failed = i + 1
print(N - failed)

Solution (Python):
def main():

    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse = True)
    totA = sum(A)
    count = 1
    for i in range(N):
        totA -= A[i]
        if 2 * totA >= A[i]:
            count += 1
        else:
            break
    return count

if __name__ == '__main__':
    print(main())

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

Solution (Python):
N = int(input())
A = sorted([int(i) for i in input().split()])
ans = 0
c = 0
for i in range(N):
    if c*2 < A[i]:
        ans = 1
    else:
        ans += 1
    c += A[i]
print(ans)

Solution (Python):


from itertools import accumulate

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

acc=[0]+list(accumulate(a))
acc.pop()
acc.pop()
cnt=1
next=a.pop()

while a and acc:
    aa=a.pop()
    ac=acc.pop()
    if (aa+ac)*2>=next:
        cnt+=1
    else:break
    next=aa

print(cnt)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = sorted(LI())


left = 0
right = n
while left <= right:
    mid = (left + right) // 2
    ret = sum(L[:mid + 1])
    i = mid + 1
    flag = False
    while ret * 2 >= L[i]:
        ret += L[i]
        i += 1
        if i >= n:
            flag = True
            break
    if flag:
        right = mid - 1
    else:
        left = mid + 1



if flag:
    print(n - mid)
else:
    print(n - mid - 1)

Solution (Python):



def main():
    from itertools import accumulate

    n = int(input())
    
    a = sorted(list(map(int, input().split())))
    sum_a = list(accumulate([0] + a))
    
    ans = [False for _ in range(n)]
    
    ans[n - 1] = True

    
    
    
    
    for i in range(n - 2, -1, -1):
        if a[i + 1] <= 2 * a[i]:
            if ans[i + 1]:
                ans[i] = True
        
        
        elif a[i + 1] <= 2 * sum_a[i + 1]:
            if ans[i + 1]:
                ans[i] = True
        else:
            ans[i] = False

    print(sum(ans))


if __name__ == '__main__':
    main()

Solution (Python):



def main():
    from itertools import accumulate

    n = int(input())
    a = sorted(list(map(int, input().split())))
    sum_a = list(accumulate([0] + a))
    ans = [False for _ in range(n)]
    ans[n - 1] = True

    for i in range(n - 2, -1, -1):
        if a[i + 1] <= 2 * a[i]:
            if ans[i + 1]:
                ans[i] = True
        elif a[i + 1] <= 2 * sum_a[i + 1]:
            if ans[i + 1]:
                ans[i] = True
        else:
            ans[i] = False

    print(sum(ans))


if __name__ == '__main__':
    main()

Solution (Python):
import heapq as hp

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

B = []
for a in A:
    hp.heappush(B, a)

ans = 1
for _ in range(N-1):
    ans += 1
    a1 = hp.heappop(B)
    a2 = hp.heappop(B)
    if a1*2 < a2:
        ans = 1
    hp.heappush(B, a1+a2)
print(ans)

Solution (Python):
import bisect, copy

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

b = copy.deepcopy(a)
for i in range(n - 1):
    b[i + 1] += b[i]

def ok(x):
    while True:
        y = bisect.bisect_right(a, b[x] * 2)
        if x == y - 1:
            return False
        if y == n:
            return True
        x = y - 1
    

lo = -1
hi = n
while abs(lo - hi) > 1:
    mi = (lo + hi) // 2
    if ok(mi):
        hi = mi
    else:
        lo = mi

print(n - hi)

Solution (Python):
n = int(input())

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l.sort()
  for i in range(n-1):
    l[i+1]+=l[i]

  
  
  ans=n
  c=1
  for i in range(n-1):
    if l[i+1]-l[i]>l[i]*2:
      ans-=c
      c=1
    else:
      c+=1

  return ans


print(main())

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

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

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

a = sorted(a)
now_size = 0
ans = 1
for i in range(n):
    if 2*now_size < a[i]:
        ans = 1
    else:
        ans += 1
    now_size += a[i]
print(ans)

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


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

A = sorted(A)
accmulate(A)

ans = N

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

print(ans)

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

    s = [a[0]]
    for i in range(1, N):
        s.append(s[-1] + a[i])
    
    
    ans = 1
    for i in range(N-2, -1, -1):
        if s[i] * 2 >= a[i+1]:
            ans += 1
        else:
            break
    print(ans)

if __name__ == "__main__":
    main()

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

Solution (Python):

def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    total, ng = 0, 0
    for i, a in enumerate(A):
        if a > total * 2:
            ng = i
        total += a
    ans = N - ng
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

from itertools import accumulate


def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    cs = [0] + list(accumulate(A))  
    ng = [i for i, (a, c) in enumerate(zip(A, cs)) if c * 2 < a]
    ans = N - max(ng)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

from itertools import accumulate


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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

    sumA = sum(A)
    ans = 0
    for i in range(N)[:: -1]:
        sumA -= A[i]
        if sumA * 2 < A[i]:
            ans = N - i
            break
    print(ans)


sol()

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
A = [int(x) for x in input().split()]

A.sort()
total = sum(A)

def test(i):
    
    size = sum(A[:i+1])
    for x in A[i+1:]:
        if size*2 >= x:
            size += x
        else:
            break
    return size == total

left = -1 
right = N-1 
while right > left + 1:
    mid = (left + right)//2
    if test(mid):
        right = mid
    else:
        left = mid

answer = N-right
print(answer)

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

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

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

A.sort()

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

print (ans)

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

Solution (Python):
n=int(input())
a=sorted(list(map(int,input().split())))
s=0
flag=0
for i,j in enumerate(a):
    if j>2*s:
        flag=i
    s+=j
print(n-flag)

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

A = np.array(A, dtype=int)
A.sort()
cs = A.cumsum()

ng = 0
for i in range(N - 1):
    if cs[i] * 2 < A[i + 1]:
        ng = i + 1
print(N - ng)

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

Solution (Python):
N = int(input())
nums= list(map(int,input().split(" ")))
nums.sort()
temp = nums[0]
cleared = nums[0]
for i in range(1,N ):
    if temp * 2 >= nums[i]:
        pass
    else:
        cleared = nums[i]
    temp += nums[i]
ans = 0
for temp in nums:
    if temp >= cleared:
        ans += 1
print(ans)

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

a.sort()

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

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

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    ans = 0
    total = 0
    for a in A:
        if total * 2 < a:
            ans = 1
        else:
            ans += 1
        total += a
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())
a = list(map(int,input().split()))
a.sort()
b = list(accumulate(a))
b = list(map(lambda x:2*x,b))
ans = 1
for i in range(n-1):
    if a[i+1] <= b[i]:
        ans += 1
    else:
        ans = 1
print(ans)

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

A = sorted(A)

ans = 1

cum = [0]*N
for i, a in enumerate(A) :
    if i == 0 :
        cum[i] = a
    
    else :
        cum[i] = cum[i-1] + a

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

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

A = sorted(A)

ans = 1

cum = [0]*N
for i, a in enumerate(A) :
    if i == 0 :
        cum[i] = a
    
    else :
        cum[i] = cum[i-1] + a

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