TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
n,c,k = map(int, input().split())
tt = sorted([int(input()) for _ in range(n)])
# print(tt)
ans = 0
limit = 0
buss = 0
for i,t in enumerate(tt):
    if buss ==0:
        limit = t+k
        buss += 1
        ans += 1
    elif buss < c and t <= limit:
            buss += 1
    if buss == c or t > limit:
            buss = 0
            if i == len(tt)-1 and buss==c:
                ans += 1
    # print(ans, t, buss, limit)

print(ans)

n,c,k = map(int, input().split())
tt = sorted([int(input()) for _ in range(n)])
print(tt)
ans = 0
limit = 0
buss = 0
for t in tt:
    if buss ==0:
        limit = t+k
        buss += 1
        ans += 1
    elif buss < c and t <= limit:
            buss += 1
    if buss == c or t > limit:
            buss = 0
    # print(ans, t, buss, limit)

print(ans)

n,c,k = map(int, input().split())
tt = sorted([int(input()) for _ in range(n)])
# print(tt)
ans = 1
limit = 0
buss = 0
for i,t in enumerate(tt):
    if i==0:
        limit = k + t
    if buss < c and t <= limit:
        buss +=1
    if buss == c and i<len(tt)-1:
        print('BUSS')
        ans += 1
        buss = 0
    elif t>limit:
        print('TIME')
        ans += 1
        buss = 0
    if buss == 0:
        limit = t + k
    # print(ans, buss, t, limit)
print(ans)

n,c,k = map(int, input().split())
tt = sorted([int(input()) for _ in range(n)])
# print(tt)
ans = 0
limit = 0
buss = 0
for t in tt:
    if buss ==0:
        limit = t+k
        buss += 1
        ans += 1
    elif buss < c and t <= limit:
            buss += 1
    if buss == c or t > limit:
            buss = 0
    # print(ans, t, buss, limit)

print(ans)

n,c,k = map(int, input().split())
tt = sorted([int(input()) for _ in range(n)])
# print(tt)
ans = 0
limit = 0
buss = 1
for i,t in enumerate(tt):
    if buss == c or t>limit:
        # print('NEED MORE BUSS')
        ans += 1
        buss = 1
        limit = t+k
    else:
        buss +=1
    # print(ans, buss, t, limit)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]

T.sort()
i = 0
ans = 0

while i < N:
    t = T[i]
    x = T.count(T[i])
    ans = ans + (x-1+C)//C
    for j in range(i+((x-1+C)//C)*C-1,N):
        if T[j]>t+K:
            y = j-i
            break
        y = N-i
            
    y=min(C,y)
    i = i + y 

print(ans)

N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]

T.sort()
i = 0
ans = 0
time =0
p = 0

for i in range(N):
 
    if  p==0 or p ==C:
        ans = ans+1
        p =1
        time =T[i]+K
    elif p<C :
        if T[i]<=time:
            p +=1
        elif T[i]>time:
            ans =ans+1
            time=T[i]+K
            p =1

print(ans)
        

Verdicts: Wrong Answer

Accepted
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
import bisect
def solve():
  n,c,k = (int(i) for i in input().split())
  t = [int(input()) for i in range(n)]
  t.sort()
  ans = 0
  
  while t:
    ans += 1
    customer = t.pop(0)
    if len(t) >= 1:
     for i in range(c):
      if customer + k >= t[0]:
        t.pop(0)
      else:
        break
  print(ans)
  
solve()

import bisect
def solve():
  n,c,k = (int(i) for i in input().split())
  t = [int(input()) for i in range(n)]
  t = sorted(t,reverse = True)
  ans = 0
  
  while t:
    ans += 1
    customer = t.pop(0)
    if len(t) >= 1:
     for i in range(c-1):
      if customer  <= t[0] + k:
        t.pop(0)
      else:
        break
      if len(t) == 0:
        break
  print(ans)
  
solve()

Verdicts: Runtime Error

Accepted
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
def a_airport_bus(N, C, K, T):
    import bisect
    t = sorted(T)
    index = 0  
    ans = 0
    while index <= N - 1:
        
        num_take_bus = bisect.bisect_right(t, t[index] + K) - index
        if num_take_bus > C:
            index += C  
        else:
            index += tmp  
        ans += 1  
    return ans

N, C, K = [int(i) for i in input().split()]
T = [int(input()) for _ in range(N)]
print(a_airport_bus(N, C, K, T))

def a_airport_bus(N, C, K, T):
    import bisect
    t = sorted(T)
    index = 0  
    ans = 0
    while index <= N - 1:
        
        num_take_bus = bisect.bisect_right(t, t[index] + K) - index
        if num_take_bus > C:
            index += C  
        else:
            index += num_take_bus  
        ans += 1  
    return ans

N, C, K = [int(i) for i in input().split()]
T = [int(input()) for _ in range(N)]
print(a_airport_bus(N, C, K, T))

Verdicts: Runtime Error

Accepted
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

out = T[0] + k
peo = 0
bus = 1

for t in T:
    if t <= out and peo <= c:
        peo += 1

    else:
        out = t + k
        peo = 1
        bus += 1

print(bus)

n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

peo = 0
bus = 1
out = T[0] + k

for t in T:
    if t <= out and peo <= c:
        peo += 1
    else:
        out = t + k
        peo = 0
        bus += 1

print(bus)

n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

out = T.pop(0) + k
peo = 1
bus = 1

for t in T:
    if t <= out and peo < c:
        peo += 1

    else:
        out = t + k
        peo = 1
        bus += 1

print(bus)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()


num_bus = 1

now = 0

time = li[0]

people_num = 0

flag = 0

while True:
    if now == n:
        break
    if li[now]-time > k:
        flag = 1
        time = li[now]
    if people_num > c:
        flag = 1
        people_num = 0
        time = li[now]
    if flag == 1:
        flag = 0
        num_bus += 1
    now += 1
    people_num += 1

print(num_bus)

from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]+[10**10]
li.sort()
bus = 1
time = li[0]
point = 1
for i in li:
    if i-time > k or point > c:
        time = i
        point = 0
        bus += 1
        continue
    point += 1
print(bus)

from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]+[10**10]
li.sort()
bus = 0
time = li[0]
point = 0
for i in li:
    if i-time > k or point > c:
        time = i
        point = 0
        bus += 1
        continue
    point += 1
print(bus)

from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()
time = li[0]
people = 0
bus_num = 1

for i in li:
    people += 1
    if i-time > k or people > c:
        bus_num += 1
        time = i
        people = 1
print(bus_num)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i.  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane. For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses. Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Submission attempts (in order):
n,c,k = map(int,input().split())
list = [int(input()) for _ in range(n)]
sorted_list = sorted(list)
bus = 1
customer = 1
max_hour = sorted_list[0]+k
for i in sorted_list[1:]:
  if i > max_hour or customer >= 3:
    bus+=1
    customer=1
    max_hour = i+k
print(bus+1 if customer != 1 else bus)

n,c,k = map(int,input().split())
list = [int(input()) for _ in range(n)]
sorted_list = sorted(list)
bus = 1
customer = 1
max_hour = sorted_list[0]+k
for i in sorted_list[1:]:
  if i > max_hour or customer >= c:
    bus+=1
    customer=1
    max_hour = i+k
print(bus+1 if customer != 1 else bus)

n,c,k = map(int,input().split())
list = [int(input()) for _ in range(n)]
sorted_list = sorted(list)
bus = 1
customer = 1
max_hour = sorted_list[0]+k
for i in sorted_list[1:]:
  if i > max_hour or customer >= c:
    bus+=1
    customer=1
    max_hour = i+k
  else:
    customer += 1
print(bus)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

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

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

			
print(N-t)

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

			
print(N-t)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
5
1 1 1 1 1

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)


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

#  if A[num]

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

#  if A[num]

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)


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

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

#cnt=0

#  if A[num]

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

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()
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)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)


n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
cnt = 1
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)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from itertools import accumulate
N = int( input())
A = list( map( int, input().split()))
A.sort()
l = -1
r = N-1
B = list( accumulate(A))
while r - l > 1:
    m = (l+r)//2
    # now = sum(A[:m+1])
    check = 1
    for i in range(m+1,N):
        if B[i] <= now*2:
            pass
        else:
            check = 0
            break
    if check == 1:
        r = m
    else:
        l = m
print(N-r)

from itertools import accumulate
N = int( input())
A = list( map( int, input().split()))
A.sort()
l = -1
r = N-1
B = list( accumulate(A))
while r - l > 1:
    m = (l+r)//2
    # now = sum(A[:m+1])
    check = 1
    for i in range(m+1,N):
        if A[i] <= B[i-1]*2:
            pass
        else:
            check = 0
            break
    if check == 1:
        r = m
    else:
        l = m
print(N-r)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

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


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)


Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

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


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)


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

A = sorted(A)

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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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


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-2,-1,-1):
  if AS[j] < 0:
    count = j+1
    break
print(len(A)-count)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np
N = int(input())
M = [0] + sorted(list(map(int, input().split())))
C = np.cumsum(M)
#print(M, C)

count = 0
for i in range(N):
  print(M[i], C[i+1])
  if C[i]*2 >= M[i+1]:
    count += 1
print(count)

import numpy as np
N = int(input())
M = [0] + sorted(list(map(int, input().split())))
C = np.cumsum(M)
#print(M, C)

count = 0
for i in range(N):
  #print(M[i], C[i+1])
  if C[i]*2 >= M[i+1]:
    count += 1
print(count)


import numpy as np
N = int(input())
M = [0] + sorted(list(map(int, input().split())))
C = np.cumsum(M)
#print(M, C)

for i in range(N-1, -1, -1):
  #print(M[i], C[i+1])
  if C[i]*2 < M[i+1]:
    #print(i)
    break
print(N-i)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

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


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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

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

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

N = int(input())

A = sorted(list(map(int,input().split())),reverse=True)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

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


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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = sorted(list(map(int, input().split())),reverse=True)
mintot = sum(a)
cnt = 1
for i in range(n):
  tot -= a[i]
  if a[i] <= tot*2:
    break
  cnt += 1
print(cnt)

n = int(input())
a = sorted(list(map(int, input().split())),reverse=True)
tot = sum(a)
cnt = 1
for i in a:
  tot -= i
  if i > tot*2:
    break
  cnt += 1
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: 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.

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

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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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]))

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

A = sorted(A)

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()

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]))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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
	sum(a) = A
	for i in range(N):
		if (A-sum_list[i])*2 >= a[i]:
			count += 1
		else:
			break

	print(count)

if __name__ == "__main__":
	main()


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()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
m = int(input())
n = list(map(int,input().split()))

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





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

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



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)


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

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

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = [int(x) for x in input().split(' ')]

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

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

print(res)


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

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

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

print(res)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import heapq
n = int(input())
A = list(map(int, input().split()))
heapq.heapify(A)

cnt = 1
prev = heapq.heappop(A)
while A:
    x = heapq.heappop(A)
    if prev > x:
        heapq.heappush(A, prev)
        prev = x
        continue
    print(prev, x, A, cnt)
    if 2*prev < x:
        cnt = 1
    else:
        cnt += 1
    prev += x

print(cnt)


n = int(input())
A = sorted(map(int, input().split()))

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

print(n-t)

Verdicts: Runtime Error

Accepted