TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
#print(a)
cnt=0
for i in range(n):
    if (x-a[i]>=0):
        cnt=cnt+1
    x=x-a[i]
print(cnt)


n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
print(a)
cnt=0
for i in range(n):
    if (x-a[i]>=0):
        cnt=cnt+1
    x=x-a[i]
    #print(x)
if x <= 0:
    print(cnt)
else:
    print(cnt-1)


n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
#print(a)
cnt=0
for i in range(n):
    if (x-a[i]>=0):
        cnt=cnt+1
    x=x-a[i]
    #print(x)
print(cnt)


n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
#print(a)
cnt=0
for i in range(n):
    if (x-a[i]>=0):
        cnt=cnt+1
    x=x-a[i]
    #print(x)
if x <= 0:
    print(cnt)
else:
    print(cnt-1)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


n,x = map(int, input().split())


a = [int(i) for i in input().split()]

a=sorted(a)

#print(a)
answer=0
for i in range(n-1):
    if x >= a[i]:
        answer += 1
        x -= a[i]
        print(x,a[i])
    else:
        break
if x == a[n-1]:
    answer += 1
print(answer)



# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


n,x = map(int, input().split())


a = [int(i) for i in input().split()]

a=sorted(a)

#print(a)
answer=0
for i in range(n-1):
    if x >= a[i]:
        answer += 1
        x -= a[i]
#        print(x,a[i])
    else:
        break
if x == a[n-1]:
    answer += 1
print(answer)



Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N, x=map(int, input().split())
a=[]
a=list(map(int, input().split()))
a.sort()
A=0
B=0
for i in range(N):
    A=A+a[i]
    if A<=x:
        B+=1
print(B)

N, x=map(int, input().split())
a=[]
a=list(map(int, input().split()))
a.sort()
A=0
B=0
for i in range(N):
    A=A+a[i]
    if A<=x:
        B+=1
if A<x:
    B=B-1
print(B)
        

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n,x=map(int,input().split())
ans=0
a=sorted(list(map(int,input().split())))
for i in range(n):
    x-=a[i]
    if x>=0:
        ans+=1
print(ans)

n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
    if x>=a[i]:
        ans+=1
        x-=a[i]
    else:
        break
if ans == n:
    if x!=0:
        ans-=1
print(x)
print(ans)

n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
for i in range(n):
    x-=a[i]
    if x<0:
        break
    else:
        if x==0:
            i+=1
print(i)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

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

s = list(map(int,input().split()))
s.sort()
print(s)
count = 0
for i in range(N):
	if k - s[i] >= 0:
		count += 1
		k -= s[i]
	else:
		break

if count == N :
	if k>0:
		count -= 1
	print(count)
else:
	print(count)

N,k = map(int,input().split())

s = list(map(int,input().split()))
s.sort()

count = 0 
for i in range(N):
	if k - s[i] >= 0:
		count += 1
		k -= s[i]
	if 0 > k:
		break 
print(count)

N,k = map(int,input().split())

s = list(map(int,input().split()))
s.sort()

count = 0 
for i in range(N):
	if k - s[i] >= 0:
		count += 1
		k -= s[i]
print(count)

N,k = map(int,input().split())

s = list(map(int,input().split()))
s.sort()

count = 0
for i in range(N):
	if k - s[i] >= 0:
		count += 1
		k -= s[i]
	else:
		break

if count == N :
	if k>0:
		count -= 1
	print(count)
else:
	print(count)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n, x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

cnt = 0
for i in a:
    if x >= i:
        cnt = cnt + 1
    else:
        break
    x = x - i

if x < 0:
    cnt = cnt - 1
print (cnt)


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

cnt = 0
for i in a:
    if x >= i:
        x = x - i
        cnt = cnt + 1
    else:
        x = x - i
        break

if x > 0:
    cnt = cnt - 1
print (cnt)


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

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

count = 0
for a in A:
    if a > X:
        break
    X -= a
    count += 1

if X > 0:
    count -= 1

print(count)

 _, X = map(int, input().split())
A = sorted(list(map(int, input().split())))

count = 0
for a in A:
    if X - a >= 0:
        X -= a
        count += 1
else:
    if count > 1 and X > 0:
        count -= 1

print(count)

_, X = map(int, input().split())
A = sorted(list(map(int, input().split())))

count = 0
for a in A:
    if X - a >= 0:
        X -= a
        count += 1

if count == len(A) and X > 0:
    count -= 1

print(count)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
# -*- coding: utf-8 -*-


#----------
n,x = list(map(int, input().rstrip().split()))
a_list = list(map(int, input().rstrip().split()))
#----------
a_list.sort()

x_remain=x
result = -1
for i in range(n):
    x_remain -= a_list[i]
    
    if x_remain < 0:
       result = i
       break

if result == -1 :
    result = n

print(result)


# -*- coding: utf-8 -*-


#----------
n,x = list(map(int, input().rstrip().split()))
a_list = list(map(int, input().rstrip().split()))
#----------
a_list.sort()
x_remain=x

result = -1
for i in range(n):
    x_remain -= a_list[i]
    
    if x_remain == 0:
        result = i+1
        break
    if x_remain < 0:
        result = i
        break

if result == -1 :
    result = n-1

print(result)


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N, x = map(int,input().split())
A = sorted(list(map(int, input().split())))
ans = 0
sum = 0
for i, A_i in enumerate(A):
	if sum + A_i <= x:
		ans = i + 1
		sum += A_i
	else:
		break
print(ans)


N, x = map(int,input().split())
A = sorted(list(map(int, input().split())))
ans = 0
su = 0
for i, A_i in enumerate(A):
	if su + A_i <= x:
		ans = i + 1
		su += A_i
	else:
		break
if sum(A) < x:
	ans -= 1
print(max(0, ans))

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
ri = lambda: list(map(int,input().split()))

n,x = ri()
a = sorted(ri())
ans = 0
c = 0
for i in a:
    c += i
    if c>=x:
        break
    ans += 1
print(ans)


ri = lambda: list(map(int,input().split()))

n,x = ri()
a = sorted(ri())
ans = 0
c = 0
for i in a:
    c += i
    if c>x:
        break
    ans += 1
print(ans)

ri = lambda: list(map(int,input().split()))

n,x = ri()
a = sorted(ri())
ans = 0
c = 0
for i in a:
    c += i
    if c>x:
        break
    ans += 1
if c<x: ans -= 1
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N,x=map(int,input().split())
children=[int(_) for _ in input().split()]
children.sort()

for i in range(len(children)):
    x-=children[i]
    if x<0:
        print(i)
        exit()

print(N)

N,x=map(int,input().split())
children=[int(_) for _ in input().split()]
children.sort()

for i in range(len(children)):
    x-=children[i]
    if x<0:
        print(i)
        exit()

if x==0 :print(N)
else:print(N-1)

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=a[0]
i=0
while s<=x and i<n-1:
  i+=1
  s+=a[i]
if i==n-1 and s<x:
  i-=1
print(i)

n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=0
i=0
while s<x:
  s+=a[i]
  i+=1
print(i+1)

n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=a[0]
i=0
while s<x:
  i+=1
  s+=a[i]
print(i)

n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=a[0]
i=0
while s<=x and i<n-1:
  i+=1
  s+=a[i]
if i==n-1 and s<x:
  i-=1
elif i==n-1:
  i+=1
print(i)

n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=a[0]
i=0
while s<=x and i<n:
  i+=1
  s+=a[i]
print(i)

n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=a[0]
i=0
while s<=x and i<n-1:
  i+=1
  s+=a[i]
if i==n-1 and s<x:
  i-=1
elif i==n-1 and s==x:
  i+=1
print(i)

n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=a[0]
i=0
while s<=x:
  i+=1
  s+=a[i]
print(i)

n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
for i in range(n):
  x=x-a[i]
  if x<0:
    break
if i==n-1 and x==0:
  i+=1
print(i)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
from itertools import accumulate
import bisect
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
A = list(accumulate(A))
ind = bisect.bisect_right(A,x)-1
if ind == -1:
    print(0)
else:
    print(ind+1)


from itertools import accumulate
import bisect
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
A = list(accumulate(A))
ind = bisect.bisect_right(A,x)-1
if ind == -1:
    print(0)
elif ind == N-1:
    if A[ind] == x:
        print(ind+1)
    else:
        print(ind)
else:
    print(ind+1)


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
cnt = 0

for i in children:
    if x - i < 0:
        break
    else:
        x -= i
        cnt += 1
        
print(cnt)


N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
cnt = 0

for i in children:
    if x - i < 0:
        break
    else:
        x -= i
        cnt += 1

print(cnt)


N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
cnt = 0

for i in children:
    cnt += 1
    if x - i < 0:
        break
    else:
        x -= i

print(cnt)


N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
cnt = 0

for i in children:
    if x - i < 0:
        break
    elif i == children[N - 1] and x - i > 0:
        print(N - 1)
    else:
        x -= i
        cnt += 1

print(cnt)


N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
sum = 0

for i in range(N):
    sum += children[i]
    if sum >= x:
        print(i + 1)
        break


N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
cnt = 0

for i in children:
    if x - i < 0:
        break
    else:
        x -= i
        cnt += 1
        
print(cnt)


N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
sum = 0

for i in children:
    sum += i

if sum < x:
    print(N - 1)

#    print(N)
else:
    cnt = 0
    for i in children:
        if x - i < 0:
            break
        else:
            x -= i
            cnt += 1
    print(cnt)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) < n:
  print(n-1)
  exit()
a.sort()
cnt = 0
i = 0
while a[i] <= n:
  cnt += 1
  n -= a[i]
  i += 1
print(cnt)

n, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) < x:
  print(n-1)
  exit()
a.sort()
cnt = 0
i = 0
while i < n and a[i] <= x:
  cnt += 1
  x -= a[i]
  i += 1
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n,x=map(int,input().split())

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

a.sort()

s=0
i=0

if n==0:
    print(0)
    exit()
elif sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(i-1)


n,x=map(int,input().split())

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

a.sort()

s=0
i=0

if sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(i-1)


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

a.sort()

s=0
i=0

if sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(s)
print(i-1)

n,x=map(int,input().split())

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

a.sort()

s=0
i=0

if sum(a)<x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(i)


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

a.sort()

s=0
i=0

if sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(i-1)

n,x=map(int,input().split())

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

a.sort()

s=0
i=0

if sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<=x:
        s+=a[i]
        i+=1

print(s)
print(i-1)


n,x=map(int,input().split())

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

a.sort()

s=0
i=0

if sum(a)<x:
    print(n)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(i)


n,x=map(int,input().split())

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

a.sort()

s=0
i=0

if sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<=x:
        s+=a[i]
        i+=1

print(i-1)


n,x=map(int,input().split())

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

a.sort()

count=0
 
if x<a[0]:
    print(0)
    exit()


for i in range(n):
    if x>=a[i]:
        x-=a[i]
        count+=1
    else:
        print(count)
        exit()

if x>0:
    print(count-1)
else:
    print(count)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N, V = list(map(int, input().split()))
C = filter(lambda x: x<=V, map(int, input().split()))
C = list(C)
N = len(C)

cnt = 0
for c in sorted(C):
  if V>0 and V-c>=0:
    cnt += 1
    V -= c
  if V<=0:
    break
print(cnt)


N, V = list(map(int, input().split()))
C = list(map(int, input().split()))
N = len(C)

if sum(C)==V:
  print(N)
else:
  cnt = 0
  for c in sorted(C):
    if V-c>0:
      cnt += 1
      V -= c
    elif V-c==0:
      cnt += 1
      break
    else:
      break
  print(min(cnt, N-1))


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

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

for i in range(N):
  b = x - A[i]
  if b > 0:
    count += 1
    x -= A[i]
  else:
    exit()
print(count)

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

A.sort()
S = 0
count = 0

for i in range(N):
  S += A[i]
  
if S < x:
  print(N-1)
  exit()
else:
  for i in range(N):
    b = x - A[i]
    if b > 0:
      count += 1
      x -= A[i]
    elif b == 0:
      count += 1  
      break
    else:
      break
  print(count)

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N, x = map(int, input())
child_list = list(map(int, input()))

nokori = x - min(child_list)
please_child = 0 
while nokori >0:
    please_child +=1
    mini = min(child_list)
    child_list.remove(mini)
    if child_list == []:
        break
    nokori -= min(child_list)
print(please_child)

x = input()
child_list = map(int, input().split())

for x>0:
  if x - min(child_list) > 0:
    please_child +=1
    child_list = child_list.pop(min(child_list))
  else:
    break
print(please_child)

N, x = map(int, input())
child_list = list(map(int, input()))

nokori = x - min(child_list)
please_child = 0 
while nokori >=0:
    please_child +=1
    mini = min(child_list)
    child_list.remove(mini)
    if child_list == []:
        break
    nokori -= min(child_list)
print(please_child)

n, x = map(int, input().split())
child_list = list(map(int, input().split()))

for x>0:
  if x - min(child_list) > 0:
    please_child +=1
    child_list = child_list.pop(min(child_list))
  if child_list == []:
    break
  if x - min(child_list) =< 0:
    break
print(please_child)

N, x = map(int, input())
child_list = list(map(int, input()))

nokori = x - min(child_list)
please_child = 0 
while nokori >=0:
    please_child +=1
    mini = min(child_list)
    child_list.remove(mini)
    if child_list == []:
        break
    if len(child_list) == 1:
        if nokori == min(child_list):
            please_child += 1
        if nokori > min(child_list):
            break
    else:    
        nokori -= min(child_list)
print(please_child)

n, x = map(int, input().split())
child_list = list(map(int, input().split()))

for x>0:
  if x - min(child_list) > 0:
    please_child +=1
    child_list = child_list.remove(min(child_list))
  if child_list == []:
    break
  if x - min(child_list) =< 0:
    break
print(please_child)

N, x = map(int, input().split())
child_list = list(map(int, input().split()))

if len(child_list) == 1:
    if x > min(child_list):
        please_child = 0
    elif x == min(child_list):
        please_child = 1
elif len(child_list) > 1:
    nokori = x - min(child_list)
    please_child = 0 
    while nokori >=0:
        please_child +=1
        mini = min(child_list)
        child_list.remove(mini)
        if child_list == []:
            break
        if len(child_list) == 1:
            if nokori == min(child_list):
                please_child += 1
            if nokori > min(child_list):
                break
            else:
            	break
        else:    
            nokori -= min(child_list)
print(please_child)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

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

ans = 0
use_list = []
for i in range(2**N):
    use_list.append(list(map(int, list(bin(i)[2::].zfill(N)))))
for u in use_list:
    s = 0
    
    for i in range(N):
        if u[i] == 1:
            s += a[i]
    if s <= x:
        ans = max(ans, sum(u))
print(ans)

N, x = map(int, input().split())
a = list(map(int, input().split()))
dp = [[]]
a.sort()
ans = 0
f = False
for b in a:
    if b <= x:
        ans += 1
        x -= b
        f = True
    else:
        f = False
if x > 0 and f:
    ans -= 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in a:
    if x-i>=0:
        x -= i
        count += 1


print(count)


n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in a:
    if x-i>=0:
        x -= i
        count += 1
    elif x-i<=0:
        break

print(count)


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

for i in range(n):
    x-=a[i]
    if x<0:
        print(i)
        break

if x >0:
    print(n-1)
elif x==0:
    print(n)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n,x = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
  if A[i] > x :
    print(ans)
    break
  else:
    x -= A[i]
    if i == N-1:
      print(N-1)
      break

N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(N):
  if A[i] <= x:
    if i == N-1:
      if x == A[i]:
        ans += 1
    else:
      x -= A[i]
      ans += 1
  else:
    break
print(ans)


Verdicts: Runtime Error

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


N, X = il()
A = sorted(il())
c = 0
for i in range(N + 1):
    if sum(A[:i]) <= X:
        c = i
print(c)


import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


N, X = il()
A = sorted(il())
if X == sum(A):
    print(N)
    exit()

for i in range(1, N + 1):
    if sum(A[:i]) > X:
        break
print(i - 1)


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n,x = map(int, input().split())
line = list(map(int, input().split()))
line.sort()
ans = 0
for i in range(n):
  x -= line[i]
  if x < 0:
    break
  else:
    ans += 1
print(ans)

n,x = map(int, input().split())
line = list(map(int, input().split()))
line.sort()
ans = 0
for i in range(n):
  x -= line[i]
  if x < 0:
    break
  else:
    ans += 1
    
  if i == n-1 and x != 0:
    ans -= 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=a[0]
y=a[1]
b.sort()
i=0
k=0
while i ==0:
	t=b[0]
	if y>=t:
		k=k+1
		del b[0]
	else:
		i=1
	if x==k:
		i=1
print(k)

a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=a[0]
y=a[1]
b.sort()
i=0
k=0
while i ==0:
	t=b[0]
	if y>=t:
		k=k+1
		y=y-t
		del b[0]
	else:
		i=1
	if x==k:
		i=1
if y>0 and x==k:
	k=k-1
print(k)

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,x = LI()
a = LI()
ans = 0
a.sort()
for y in a:
    if x>=y:
        x -= y
        ans += 1
    else:
        break
print(ans) 


import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,x = LI()
a = sorted(LI())
ans = 0
if a[0]>x:
    pass
else:
    for i in range(N):
        if i!=N-1 and a[i+1]<=x:
            x -= a[i]
            ans += 1
        elif i!=N-1 and a[i+1]>x:
            if a[i]==x:
                ans += 1
                break
        else:
            if a[i]==x:
                ans += 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
#coding: utf-8
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
a.sort()
for i in range(len(a)):
    x -= a[i]
    ans += 1
    if x < 0:
        ans -= 1
print(ans)

#coding: utf-8
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
a.sort()
for i in range(len(a)):
    x -= a[i]
    ans += 1
    if x < 0:
        ans -= 1
print(ans if x <= 0 else ans - 1)

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n, x = map(int, input().split())
a = list(map(int, input().split()))

l = sorted(a)
flag = False
for i in range(n):
    x -= l[i]
    if x < 0:
        flag = True
        break
if flag:
    print(i)
else:
    print(n)

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

l = sorted(a)
flag = False
for i in range(n):
    x -= l[i]
    if x < 0:
        flag = True
        break
if flag:
    print(i)
elif x = 0:
    print(n)
elif x > 0:
    print(n - 1)

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

l = sorted(a)
flag = False
for i in range(n):
    x -= l[i]
    if x < 0:
        flag = True
        break
if flag:
    print(i)
elif x == 0:
    print(n)
elif x > 0:
    print(n - 1)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

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

max = 0
for i in range(1, N + 1):
  if sum(sorted(alist)[:i]) <= x:
    max = i
print(max)

N, x = map(int, input().split())
alist = list(map(int, input().split()))

max = 0
alist.sort()
for i in range(0, N):
  x -= alist[i]
  if x < 0:
    max = i
    break
  if x == 0:
    max = i + 1
    break
print(max)

N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
max = 0
for i in range(1, N + 1):
  if sum(a[:i]) <= x:
    max = i
if sum(a[:N + 1]) < x:
  print(N - 1)
else:
  print(max)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
def main():
    N, x = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    num = 0
    for i in sorted(a):
        x -= i
        if x >= 0:
            num += 1
        else:
            break

    print(num)


if __name__ == '__main__':
    main()

def main():
    N, x = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    num = 0
    for i in sorted(a):
        x -= i
        if x >= 0:
            num += 1
        else:
            break
    if x > 0:
        num -= 1
    print(num)


if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N,x=map(int,input().split())
l=list(map(int,input().split()))
ans=0
l.sort()

for n in range(N):
    if l[n]<x:
        x-=l[n]
        ans+=1
    elif l[n]==x:
        x-=l[n]
        ans+=1
        break
    else:
        break

print(ans)

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

for n in range(N):
    if n!=N-1:
        if l[n]<x:
            x-=l[n]
            ans+=1
        elif l[n]==x:
            x-=l[n]
            ans+=1
            break
        else:
            break
    else:
        if l[n]==x:
            x-=l[n]
            ans+=1
        else:
            break

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
import itertools
import bisect
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cumsum = list(itertools.accumulate(A))
ans = bisect.bisect_right(cumsum,x)
print(ans)


import itertools
import bisect
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cumsum = list(itertools.accumulate(A))
ans = bisect.bisect_right(cumsum,x)

if ans == N:
  rest = cumsum[N] - x
  if rest != 0:
    ans -= 1

print(ans)


import itertools
import bisect
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cumsum = list(itertools.accumulate(A))
ans = bisect.bisect_right(cumsum,x)

if ans == N:
  rest = cumsum[-1] - x
  if rest != 0:
    ans -= 1

print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N,x=map(int,input().split())
A=sorted(map(int,input().split()))
a=[0]*len(A)
a[0]=A[0]
count=0
for i in range(1,len(A)):
    a[i]=A[i]+a[i-1]
for i in range(len(A)):
    if a[i]<=x:
        count+=1
print(count)

N,x=map(int,input().split())
a=sorted(map(int,input().split()))
count=0
for i in range(N-1):
    x=x-a[i]
    if x>=0:count+=1
if x==a[N-1]:count+=1
print(count)

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for i in range(n):
  if a[i] <= x:
    x -= a[i]
    cnt += 1
  else:
    break
print(cnt)

n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for i in a:
  if i > x:
    break
  x -= i
  cnt += 1
else:
  if x > 0:
    cnt -= 1
print(cnt)


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n, x = map(int, input().split(" "))
a = tuple(map(int, input().split(" ")))

for i, a_i in enumerate(sorted(a)):
    x -= a_i
    if x < 0:
        print(i)
        exit()
print(n)

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

a.sort()

count = 0
for a_i in a:
    x -= a_i
    if x < 0:
        break
    count += 1
print(count)


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

a.sort()

count = 0
for a_i in a:
    x -= a_i
    if x >= 0:
        count += 1
print(count)


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

a.sort()

for i in range(n):
    x -= a[i]
    if x < 0:
        print(i)
        exit()
print(n)


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

a.sort()

for i in range(n):
    x -= a[i]
    if x < 0:
        print(i)
        exit()
    elif x == 0:
        print(i+1)
        exit()
print(n)

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

for i, a_i in enumerate(sorted(a)):
    x -= a_i
    if x <= 0:
        print(i)
        exit()
print(n)

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

a.sort()

for i in range(n):
    x -= a[i]
    if x <= 0:
        print(i+1)
        exit()
print(n)


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

a.sort()

count = 0
for a_i in a:
    x -= a_i
    if x < 0:
        break
    count += 1
print(count-(x>0))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
n, x = map(int, input().split())

lis = map(int, input().split())


count = 0
for i in sorted(lis):
    x -= i
    if x < 0:
        break
    count += 1

print(count)


n, x = map(int, input().split())

lis = map(int, input().split())


count = 0
for i in sorted(lis):
    x -= i
    if x < 0:
        break
    count += 1

if x > 0:
    count -= 1

print(count)


Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N, x = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

A.sort()

count = 0
for i in range(N):
    count += A[i]
    if count > x:
        break

print(i + 1 if i >= N - 1 else i)

from itertools import accumulate
from bisect import bisect_right

N, x, *A = map(int, open(0).read().split())

A.sort()
S = list(accumulate(A))

if S[-1] == x:
    print(N)
else:
    print(min(N - 1, bisect_right(S, x)))

Verdicts: Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
s = x
cnt = 0
if sum(a) > s:
    print(N-1)
elif s >= a[0]:
    for i in range(N):
        if s >= a[i]:
            cnt += 1
            s -= a[i]
    print(cnt)

N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
s = x
cnt = 0
if sum(a) < s:
    print(N-1)
if s >= a[0]:
    for i in range(N):
        if s >= a[i]:
            cnt += 1
            s -= a[i]
    print(cnt)

N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
s = x
cnt = 0
if s > sum(a):
    print(N-1)
elif (s >= a[0] and s <= sum(a)):
    for i in range(N):
        if s >= a[i]:
            cnt += 1
            s -= a[i]
    print(cnt)
else:
    print(0)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N children, numbered 1, 2, ..., N.  Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.  For each i (1 \leq i \leq N), Child i will be _happy_ if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy children by optimally distributing the sweets. Find the maximum possible number of happy children.

Submission attempts (in order):
import sys
N, x = map(int, input().split())
a = sorted(map(int, input().split()))

ans = 0
score_x  = x

for  i in range(N):
    if score_x < a[i]:
        print(0)
        sys.exit()

    elif score_x  >= a[i]:
        score_x = (score_x - a[i])
        ans = ans + 1

print(ans)

import sys
N, x = map(int, input().split())
a = sorted(map(int, input().split()))


ans = 0
score_x  = x

if score_x < a[0]:
    print(0)
    sys.exit()
    
for  i in range(N):

    if score_x  >= a[i]:
        score_x = (score_x - a[i])
        ans = ans + 1


print(ans)

import sys
N, x = map(int, input().split())
a = sorted(map(int, input().split()))


ans = 0
score_x  = x

if score_x < a[0]:
    print(0)
    sys.exit()
    
for  i in range(N):
    if i == (N-1):
        if a[i] == score_x:
            ans = ans + 1
            score_x = (score_x - a[i])
        else:
            break      
    if score_x  >= a[i]:
        score_x = (score_x - a[i])
        ans = ans + 1


print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted