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

A = sorted(A)

wa = A[0]  # i - 1 までの和
cnt = 1  # i 番目の生き物より小さかったのに、i 番目の生き物を食べれるやつの数
for i in range(1, N):
    if 2 * wa >= A[i]:
        cnt += 1
    else:
        cnt = 1
    wa += A[i]
    print(cnt)

Submission status: Wrong Answer

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

A = sorted(A)

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

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from bisect import *
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(accumulate(A))
s = A[-1]
t = s
while True:
    t = A[bisect_left(A,s/2)]
    if t != s:
        s = t
    else:
        break
k = bisect_left(B,t/2)
print(N-k)

Submission status: Wrong Answer

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

asum=[A[0]]
j=1
for i in range(1,N):
    if asum[i-1]*2<A[i]:
        ans-=j
        j=1
    asum.append(asum[i-1]+A[i])
    j+=1

print(ans)

Submission status: Wrong Answer

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

asum=[A[0]]

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

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    now = a[0]
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(n - 1):
        if b[i + 2] - b[i + 1] > now * 2:
            ans = n - i - 1
            break
        else:
            now = b[i + 1]

    print(ans)

main()

Submission status: Wrong Answer

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

    print(ans)

main()

Submission status: Wrong Answer

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

    print(ans)

main()

Submission status: Wrong Answer

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

    print(ans)

main()

Submission status: Wrong Answer

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

    print(ans)

main()

Submission status: Wrong Answer

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

small = []
now_not_small = []
for i in range(N - 1):
    if (sum(small) + A[i]) * 2 < A[i + 1]:
        small.append(A[i])
        for i in now_not_small:
            small.append(i)

        now_not_small = []
        continue

    elif sum(small) + A[i] * 2 >= A[i + 1]:
        now_not_small.append(A[i])

print(len(A) - len(small))

Submission status: Wrong Answer

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

small = []
now_not_small = []
for i in range(N - 1):
    if (sum(small) + A[i]) * 2 < A[i + 1]:
        small.append(A[i])
        small.extend(now_not_small)
        now_not_small = []
        continue

    elif sum(small) + A[i] * 2 >= A[i + 1]:
        now_not_small.append(A[i])

print(len(A) - len(small))

Submission status: Wrong Answer

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

small = []
for i in range(N - 1):
    if (sum(small) + A[i]) * 2 < A[i + 1]:
        small.append(A[i])


print(len(A) - len(small))

Submission status: Wrong Answer

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

c_sum = al[0]
cnt = 1
max_cnt = 1
for a in al[1:]:
    if c_sum*2 >= a:
        c_sum += a
        cnt += 1
    else:
        c_sum += a
        max_cnt = max(max_cnt,cnt)
        cnt = 1

ans = max(max_cnt,cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
x = list(map(int,input().split()))
x.sort()
x_cm = np.cumsum(x)[::-1]

count = 1
for i in range(N-1):
    if x[i+1]<=x[i]*2:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    cnt = 1
    for i in range(n-1):
        if a[i] <= a[i+1]*2:
            cnt += 1
    print(cnt)
        

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
a = sorted(A)
res = list(np.cumsum(a))

ans = 0
idx = 1
for i in range(len(res)):
    num = res[i]
    while(num*2 >= a[idx]):
        num += a[idx]
        idx += 1
        
        if(idx == len(res)-1):
            break
       
    if(idx == len(res)-1):
        print(N-i)
        break

Submission status: Wrong Answer

Solution code:
from itertools import*
n, *a = map(int, open(t := 0).read().split())
a.sort();*b, = accumulate(a)
for i in range(1, n):
  if 2 * b[i - 1] < a[i]:t = i;break
print(n - t)

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
#print(a)
x=bisect.bisect_left(a,a[-1]/2)
#print(x)
ans=n-x#そのままの状態で条件を満たす和
if x==0:
    print(ans)
    exit()
i=x-1
j=x
tmp=a[i]
ref=a[x]
while True:
    if tmp*2<ref:
        if i==0:
            break
        tmp+=a[i-1]
    else:
        ans+=1
        if i==0:
            break
        j-=1
        ref=a[j]
    i-=1
print(ans)

Submission status: Wrong Answer

Solution code:
n, *aa = map(int, open(0).read().split())

aa.sort()

count = 1
tmp = aa[0]
for i in range(1,n):
    if 2 * tmp >= aa[i]:
        tmp += aa[i]
        count += 1
    else:
        tmp += aa[i]
        count = 1
    print(count, tmp)

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy
n=int(input())
a=list(map(int,input().split()))
a.sort()
c=i=st=0

while i <n-1:
  if 2*(a[st]+c) >= a[i+1]:
    c+=a[i+1]
    i+=1
  else:
    st=i+1
    c=a[st]+c
    i+=1
print(n-st)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left

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

#print(a[-1], total)
index = bisect_left(total, a[-1] / 2, 0, n)
#print(index)
print(n - index)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AtoZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

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

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()
L = IL()
L.sort()

i = 0
now = 0
flag = 0
while i<N:
  now += L[i]
  if i != N-1:
    if L[i]*2 <= L[i+1]:
      flag = i
  i += 1
  
print(N-flag)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n = int(input())
a = sorted(list(map(int,input().split())))
a1 = list(accumulate(a))
bit = 0
for i in range(n-1):
  for j,k in zip(a[i+1:],a1[i:]):
 #   print(j,k)
    if 2*k<j:
      bit = 1
      break
    elif bit==1 and 2*k>=j:
      print(n-i)
      exit()
      
else:
  print(n)

Submission status: Wrong Answer

Solution code:
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res
n = int(input())
data = list(map(int, input().split()))
cnt = count(data)
monsters = sorted(cnt.keys())
total = sum(data)
ans = n
idx = len(monsters)-2
while idx >= 0:
    prev = monsters[idx+1]
    total -= prev*cnt[prev]
    if total*2 < prev:
        break
    idx -= 1

ans -= max(0, idx+1) 
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=list(map(int, input().split()))
A=sorted(A, reverse=True)
MAX=A[0]
now=A[0]
border=-1
for i in range(1,N):
    if A[i]*2>=MAX:
        now=A[i]
    else:
        border=i
        break
if border==-1:
    print(N)
    exit()
#print(now) #普通に全部食える
rest=A[border:]
#print(rest)
cum=np.cumsum(rest[::-1])[::-1]
adds=[-1]*(len(rest))
adds[0]=cum[0]
for i in range(1,len(cum)):
    if cum[i]*2>=rest[i-1]:
        adds[i]=adds[i-1]
    else:
        adds[i]=adds[i-1]-rest[i-1]
#print(cum)
#print(adds)
adds=np.array(adds)
add=(adds*2>=now).sum()

print(border+add)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=list(map(int, input().split()))
A=sorted(A, reverse=True)
MAX=A[0]
now=A[0]
border=-1
for i in range(1,N):
    if A[i]*2>=MAX:
        now=A[i]
    else:
        border=i
        break
if border==-1:
    print(N)
    exit()
#print(now) #普通に全部食える
rest=A[border:]
#print(rest)

add=(np.cumsum(rest)*2>=now).sum()
print(border+add)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(map(int,input().split()))
p=1
for i in range(n-1):
    p+=a[i]*2>=a[i+1]
print(p)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
print(A[0:2])
ans=0
for i in range(N):
    Sum = sum(A[0:i+1])
    for j in range(i+1,N):
        if Sum*2 >= A[j]:
            Sum+=A[j]
            #print("i,j,Sum",i,j,Sum,ans)
            if j == N-1:
                ans += 1
print(ans+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
cnt = 0
for i in range(n-1):
    S[i+1] = S[i] + L[i+1]
    if L[i+1] <= 2 * S[i]:
        cnt += 1
    else:
        cnt = 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
for i in range(n-1):
    S[i+1] = S[i] + L[i]
    if L[i+1] > 2 * S[i]:
        print(n - i - 1)
        break
else:
    print(n)

Submission status: Wrong Answer

Solution code:
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
for i in range(n-1):
    S[i+1] = S[i] + L[i]
    if L[i+1] > 2 * S[i]:
        print(n - i)
        break
else:
    print(n)

Submission status: Wrong Answer

Solution code:
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
for i in range(n-1):
    S[i+1] = S[i] + L[i]
    if S[i+1] > 2 * S[i]:
        print(n - i)
        break
else:
    print(n)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

n = int(input())
arr = np.array(list(map(int, input().split())))

arr.sort()
arr_cs = arr.cumsum()

for i in range(n - 1):
    if arr_cs[i] * 2 < arr[i + 1]:
        print(n - i - 1)
        sys.exit()
else:
    print(n)

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定



# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n = int(input())
a = sorted(list(map(int, input().split())))
c = [0 for i in range(n)]
for i in range(n):
    if i == 0:
        c[i] - a[i]
    else:
        c[i] = c[i - 1] + a[i - 1]
# print("c =", c)
ans = n
for i in range(n):
    if c[i] != 0 and c[i] * 2 < a[i]:
        ans -= i
        break
print(ans)

Submission status: Wrong Answer

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

set_A = set(A)
if len(set_A) == 1:
    print(len(A))
    exit()
    
tmp_slime = A[0]
tmp_flag = True
for i in range(1, len(A)):
    if tmp_slime*2 >= A[i]:
        tmp_slime += A[i]
    else:
        tmp_flag = False
        break
if tmp_flag:
    print(len(A))
    exit()

A = sorted(A)
low = 0
high = len(A)-1
mid = (low + high) // 2
while True:
    tmp = mid
    slime = sum(A[0:mid+1])
    flag = True
    for i in range(mid+1, len(A)):
        if slime*2 >= A[i]:
            slime += A[i]
        else:
            flag = False
            break
    if flag:
        high = mid
        mid = (low + high) // 2
    else:
        low = mid
        mid = (low + high) // 2
    if mid == tmp:
        break
    
print(len(A) - len(A[0:mid+1]))

Submission status: Wrong Answer

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

set_A = set(A)
if len(set_A) == 1:
    print(len(A))
    exit()

A = sorted(A)
low = 0
high = len(A)-1
mid = (low + high) // 2
while True:
    tmp = mid
    slime = sum(A[0:mid+1])
    flag = True
    for i in range(mid+1, len(A)):
        if slime*2 >= A[i]:
            slime += A[i]
        else:
            flag = False
            break
    if flag:
        high = mid
        mid = (low + high) // 2
    else:
        low = mid
        mid = (low + high) // 2
    if mid == tmp:
        break
    
print(len(A) - len(A[0:mid+1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
As.sort()
from itertools import accumulate
cum = accumulate(As)
cnt = 0
for n in range(N-1):
    if As[n]*2<As[n+1]:
        cnt += 1
print(N-cnt)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc011/tasks/agc011_b
from heapq import heapify, heappop, heappush
n = int(input())
nums = [int(i) for i in input().split()]
heapify(nums)
ans = 0
if len(nums) % 2 == 1:
    ans += 1
MAX = max(nums)
while len(nums) != 1:
    s = heappop(nums)
    t = heappop(nums)
    if s * 2 >= t:
        ans += 1
    heappush(nums, s + t)
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
d=[0]*n
d[0]=1
s=[0]*n
s[0]=a[0]

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

Submission status: Wrong Answer

Solution code:
n=int(input())

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

t.sort(reverse=True)

max_wight = t[0]

count = 0

for i in range(n):
    if t[i] <= max_wight//2:
        break
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
M = [0] + sorted(list(map(int, input().split())))
C = np.cumsum(M)
#print(M, C)
#2分探索とかbreakでも良さそうだけど
count = 0
for i in range(N):
  #print(M[i], C[i+1])
  if C[i]*2 >= M[i+1]:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
M = [0] + sorted(list(map(int, input().split())))
C = np.cumsum(M)
#print(M, C)
#2分探索とかbreakでも良さそうだけど
count = 0
for i in range(N):
  print(M[i], C[i+1])
  if C[i]*2 >= M[i+1]:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    res = A[0]
    cnt = 1
    for i in range(1, N):
        a = A[i]
        if a <= 2 * res:
            res += a
            cnt += 1
        else:
            break

    if cnt == N:
        print(N)
    else:
        print(N - cnt)

Submission status: Wrong Answer

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

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

left=0
for left in range(N-2,-1,-1):
  if B[left]*2>=A[left+1]:
    pass
  else:
    break

num=N-left-1
#print(left)
print(num)

#cnt=0
#for i in range(num,N-1):
#  if A[num]

Submission status: Wrong Answer

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

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

left=0
for left in range(N-2,-1,-1):
  if B[left]*2>=A[left+1]:
    pass
  else:
    break

num=N-left-1
#print(left)
#print(num)

#cnt=0
#for i in range(num,N-1):
#  if A[num]

Submission status: Wrong Answer

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

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

left=0
for left in range(N-2,-1,-1):
  if B[left]*2>=A[left+1]:
    pass
  else:
    break

num=N-left-1
print(num)

#cnt=0
#for i in range(num,N-1):
#  if A[num]

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
S = list(accumulate(A))
AS = []
flg = False
count = 0

for i in range(N-1):
  AS.append(S[i]*2 - A[i+1])
for j in range(N-1):
  if AS[j] < 0:
    flg = True
  elif AS[j] >= 0 and flg:
    count = j
    break
print(len(A)-count)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
S = [0]+list(accumulate(A))
AS = [0]*N
count = 0

for i in range(N):
  AS[i] = A[i]+S[i]

for i in range(N):
  num = AS[i]
  for j in range(i+1,N):
    print(A[j])
    if num*2 >= A[j]:
      num += A[j]
      if j == N-1:
        ans = len(A)-count
        print(ans)
        exit()
    else:
      count += 1
      break

Submission status: Wrong Answer

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

a.sort()
count1=0
count2=0
for i in range(n-1):
    count1+=a[i]
    if 2*count1<a[i+1]:
        count2+=i+1
print(n-count2)

Submission status: Wrong Answer

Solution code:
#B
from itertools import accumulate

n = int(input())
a = [int(i) for i in input().split()]
a.sort()
accum = list(accumulate(a))

accum.reverse()
ind = 1
while(ind < n):
    if accum[ind]*2 >= a[ind-1]:
        ind += 1
    else:
        break
    
print(ind)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect
N=int(input())
A=sorted(list(map(int,input().split(' '))))
ans = 1
for n,i in enumerate(A[:-1]):
    x=bisect.bisect_right(A,i*2)
    while x!=n+1:
        i*=2
        x=bisect.bisect_right(A,i)
        if x==N:
            ans += 1
            break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n = int(readline())
a = sorted(tuple(map(int, readline().split())))
cnt = 1
cumsum = list(itertools.accumulate(a))

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=sorted(list(map(int,input().split())))
ans,s=0,0
for u in l:
  if 2*s>=u:ans+=1
  s+=u
print(ans)

Submission status: Wrong Answer

Solution code:
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}
  elif a > prev_sum*2:
    color_set = {color}
  prev_sum += a
  prev_num = a
print(len(color_set))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=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)

Submission status: Wrong Answer

Solution code:
#B - Colorful Creatures
N = int(input())
A = list(map(int, input().split()))
A.sort()
tmp = 0
for i in range(N-1):
    if A[i+1] <= 2*A[i]:
        tmp += 1
        A[i+1] = A[i]+A[i+1]
    else:
        pass

print(N-tmp)

Submission status: Wrong Answer

Solution code:
#B - Colorful Creatures
N = int(input())
A = list(map(int, input().split()))
A.sort()
tmp = 0
for i in range(N-1):
    if A[i+1] < 2*A[i]:
        tmp += 1
        A[i+1] = A[i]+A[i+1]
    else:
        pass

print(N-tmp)