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 = map(int, input().split())
a_sorted = sorted(a)
sum = 0
for i in range(N):
  if sum > x:
    print(i - 1)
    break
  else:
    sum += a_sorted[i]
    if i == N-1:
      print(i -1)

N, x = map(int, input().split())
a = map(int, input().split())
a_sorted = sorted(a)
if sum(a_sorted) <= x:
  print(N)
else:
  i = 0
  a_sum = 0
  while a_sum <= x:
    a_sum += a_sorted[i]
    i += 1
  print(i - 1)

N, x = map(int, input().split())
a = map(int, input().split())
a_sorted = sorted(a)
if sum(a_sorted) == x:
  print(N)
elif sum(a_sorted) <= x:
  print(N - 1)
else:
  i = 0
  a_sum = 0
  while a_sum <= x:
    a_sum += a_sorted[i]
    i += 1
  print(i - 1)

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()))
a.sort()
ans=-1
num=0
for i in range(n):
    num+=a[i]
    if num>x:
        ans=i
        break
if ans==-1:
    print(n)
else:
    print(ans)


n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=-1
num=0
for i in range(n):
    num+=a[i]
    if num>x:
        ans=i
        break
if ans==-1:
    if num==x:
        print(n)
    else:
        print(n-1)
else:
    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 ai in a:
	if x <= 0:
		break
	if x >= ai:
		x -= ai
		count += 1

print(count)

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

count = 0
for ai in a:
	if x >= 0 and x < ai:
		break
	else:
		x -= ai
		count += 1
else:
	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):
a,b,*x=map(int,open(0).read().split())
x=sorted(x)
count=0
for s in x:
    b-=s
    if b<0:
        break
    count+=1
print(count)

n,m,*a=map(int,open(0).read().split());b=sum(a);c=0
for i in sorted(a):
    b-=i
    c+=1
    if b<=0:
        print(c)
        exit()

a,b,*x=map(int,open(0).read().split())
x=sorted(x)
count=0
for s in x:
    b-=s
    if b<0:
        break
    count+=1
if b>0:
    print(count-1)
else:
    print(count)

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()))
a.sort(key=int)
ans=0
for i in range(n):
  x=x-a[i]
  if x<0:
    x=x+a[i]
  else:
    ans+=1
if ans==n:
    if (x-sum(a))>0:
        print(ans-1)
    else:
        print(ans)
else:
    print(ans)

n,x=map(int,input().split())
a=list(map(int,input().split()))
ar=a.sort(reverse=True,key=int)
ans=0
for i in range(n):
  x-=ar[i]
  if x<0:
    x+=ar[i]
  else:
    ans+=1
print(ans)
  

n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort(key=int)
ans=0
for i in range(n):
  x=x-a[i]
  if x<0:
    x=x+a[i]
  else:
    ans+=1
if ans==n:
    if x>0:
        print(ans-1)
    else:
        print(ans)
else:
    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(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
total = 0
index = 0
for i in range(N):
    total += num_list_s[i]
    if total > X:
        break
    else:
        index += 1
if sum(num_list) < x:
    print(index-1)
else:
    print(index)

N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
total = 0
index = 0
for i in range(N):
    total += num_list_s[i]
    if total > X:
        break
    else:
        index += 1
print(index)
    

N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
sum = 0
index = 0
for i in range(N):
    sum += num_list_s[i]
    if sum > X:
        break
    else:
        index += 1
print(index)
    

N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
total = 0
index = 0
for i in range(N):
    total += num_list_s[i]
    if total > X:
        break
    else:
        index += 1
if sum(num_list) < X:
    print(index-1)
else:
    print(index)

Verdicts: Runtime Error

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

ans = 0
for i in l:
    if i <= x:
        x -= i
        ans += 1
print(ans)

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

ans = 0
for i in l:
    if i <= x:
        x -= i
        ans += 1
if ans == n and x > 0:
    print(ans-1)
else:
    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())
li = list(map(int,input().split()))
list.sort(li)
total = 0
num = 0
for i in range(n):
    if total + li[i] >= x:
        num = i + 1
        break
    elif i == n - 1:
        num = i + 1
    else:
        total += li[i]
print(num)


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


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):
# agc027_a.py
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt = 0
for i in a:
    if x>=i:
        cnt += 1
        x -= i
print(cnt)

# agc027_a.py
n,x = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) == x:
    print(n)
    exit()

a.sort()
cnt = 0
for i in a:
    if x>=i:
        cnt += 1
        x -= i
if cnt == n:
    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=sorted(list(map(int,input().split())))
ans=0
cnt=0
for i in range(n):
    cnt+=a[i]
    if cnt<=x:
        ans+=1
    else:
        break
print(ans)

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

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

import sys
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
ans=0
cnt=0
if x==sum(a):
    print(n)
    sys.exit()
for i in range(n):
    x-=a[i]
    if x<0:
        print(i)
        sys.exit()
else:
    print(n-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):
if __name__ == "__main__":
    N,x = list(map(int, input().split()))
    a = list(map(int, input().split()))
    A = 0

    a.sort()
    print(a)
    while x >= 0:
        if a[-1] < x:
            x -= a.pop(-1)
            A += 1
        else:
            break

    if x != 0:
        A -= 1
    print(A)


if __name__ == "__main__":
    n, x = map(int, input().split())
    aaa = list(map(int, input().split()))
    
    for a in sorted(aaa):
        if x < a:
            break
        ans += 1
        x -= a
    else:
        if x > 0:
            ans -= 1
    print(ans)

if __name__ == "__main__":
    n, x = map(int, input().split())
    aaa = list(map(int, input().split()))
    aaa.sort()
    ans = 0
    print(aaa)
    for a in aaa:
        if x < a:
            break
        ans += 1
        x -= a
#     else:
#         if x > 0:
#             ans -= 1
    print(ans)

if __name__ == "__main__":
    n, x = map(int, input().split())
    aaa = list(map(int, input().split()))
    ans = 0
    
    for a in sorted(aaa):
        if x < a:
            break
        ans += 1
        x -= a
    else:
        if x > 0:
            ans -= 1
    print(ans)

Verdicts: Runtime Error

Runtime Error

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):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

A = sorted(A, reverse=True)

ans = N
sumA = sum(A)
for a in A:
    if sumA > x:
        sumA -= a
        ans -= 1
    else:
        break
print(ans)


import bisect

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

A = sorted(A)

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

ans = 0
ind = bisect.bisect_right(A, x)
if ind == 0:
    ans = 0
elif ind >= N:
    if A[-1] == x:
        ans = N
    else:
        ans = N-1
else:
    ans = ind
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,M = map(int,input().split())
L = input().split()

L = sorted(L)

total = 0
i = 0
while M > 0 and i < N:
    M -= int(L[0])
    L.pop(0)
    total += 1
    i += 1

print(total)

N,M = map(int,input().split())
L = map(int,input().split())

L = sorted(L)

total = 0
for i in range(N):
    if M - int(L[0]) >= 0:
        M -= int(L[0])
        total += 1
        L.pop(0)
        
print(total)

N,M = map(int,input().split())
L = map(int,input().split())

L = sorted(L)

total = 0
i = 0
for i in range(N):
    if M - int(L[0]) > 0:
        M -= int(L[0])
        total += 1
        L.pop(0)
        i += 1
        
print(total)

N,M = map(int,input().split())
L = map(int,input().split())

L = sorted(L)

total = 0
for i in range(N):
    if M - int(L[0]) >= 0:
        M -= int(L[0])
        total += 1
        L.pop(0)
        
print(total)

N,M = map(int,input().split())
L = map(int,input().split())

L = sorted(L)

total = 0
for i in range(N):
    if M - int(L[0]) >= 0:
        M -= int(L[0])
        total += 1
        L.pop(0)

if total == N and not M == 0:
    total = N - 1
        
print(total)

Verdicts: 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 = list(map(int, input().split()))
a_list.sort()
give = 0
count = 0

for num in a_list:
    give += num
    if give > x:
        break
    count += 1

print(count)


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

a_list = list(map(int, input().split()))
a_list.sort()
give = 0
count = 0

for num in a_list:
    give += num
    if give == x:
        count += 1
        break
    if give > x:
        count -= 1
    count += 1

if give < x:
    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 = sorted(a)

count = 0

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

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

a = sorted(a)
count = 0

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

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

a = sorted(a)

count = 0

for i in range(n - 1):
    if a[i] <= x:
        x -= a[i]
        count += 1
    else:
        break

if a[-1] == x:
    count += 1

print(count)

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()))
a.sort()
s = [0] * (n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]

ans = 0
for i in range(n):
    if x >= s[i+1]:
        ans = i+1
print(ans)

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

ans = 0
for i in range(n):
    if x >= s[i+1]:
        ans = i+1
if x > s[n]:
    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()))
ans = 0
a = sorted(a, reverse = True)
for i in range(len(a)):
	if x >= a[i]:
		x -= a[i]
		ans += 1
print(ans)

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

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

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


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


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


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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

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):
temp = input().rstrip().split(" ")
N = int(temp[0])
X = int(temp[1])
list = input().rstrip().split(" ")
list.sort()
print(list)
c = 0
for i in range(N):
    X = X - int(list[i])
    if X >= 0:
       c += 1
    else:
        break
if X <= 0:
    print(c)
elif X > 0:
    print(c-1)

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

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())))
count = 0
for i in a:
    x -= i
    count += 1
    if x == 0:
        count += 1
        break
    elif x < 0:
        count -= 1
        break
print(count)

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

N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in a:
    x -= i
    if x == 0:
        count += 1
        break
    elif x < 0:
        break
    else:
        count += 1
print(count)
        

N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in range(N):
    x -= a[i]
    count += 1
    if x == 0:
        break
    elif x < 0:
        count -= 1
        break
    elif (i == (len(a) - 1)) and (x > 0):
        count -= 1
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())
li = list(map(int,input().split()))

li.sort()
ans = 0

for i in range(n):
    x =  x-li[i]
    if x < 0:
        ans = i
        break
    ans = i+1
print(ans)


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

if x < min(A):
    print(0)
    exit()

A.sort()
ans = 0
i = 0
while x > 0 and ans < N:
    if x >= A[i]:
        x -= A[i]
        ans += 1
        i += 1
    else:
        x = 0
        break

if 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):
nx = [int(i) for i in input().split()]
n = nx[0]
x = nx[1]
a = [int(i) for i in input().split()]
b =list(sorted(a))
s = 0
ans = 0
for i in range(n+1):
    if sum(b[:i])<=x:
        s = sum(b[:i])
        ans = i
print(ans)


nx = list(map(int,input().split()))
n=nx[0]
x=nx[1]
a=list(map(int,input().split()))
b=sorted(a)
ans = 0
g = 0
i=0
for i in range(n):
    if g + b[i] <= x:
        ans = i + 1
        g = g + b[i]
        if i == n-1 and g != x:
            ans = 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):
from sys import stdin
N,x=[int(x) for x in stdin.readline().rstrip().split()]
data=[int(x) for x in stdin.readline().rstrip().split()]
data=sorted(data)
ans=0
if data[0] < x:
    print(0)
else:
    for i in data:
        x=x-i
        if x <= 0:
            break
        ans+=1
    if x!=0 and ans !=1:
        ans-=1
    print(ans)

from sys import stdin
N,x=[int(x) for x in stdin.readline().rstrip().split()]
data=[int(x) for x in stdin.readline().rstrip().split()]
data=sorted(data)
ans=0
if data[0] > x:
    print(0)
else:
    for i in data:
        x=x-i
        if x < 0:
            break
        ans+=1
    if x > 0 and x!=0 and ans !=1:
        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 = [int(x) for x in input().strip().split()]
an = sorted([int(a) for a in input().strip().split()])
cumsum = 0
for i, a in enumerate(an, start=1):
  cumsum += a
  if cumsum > x:
    break
else:
  i += 1
print(i-1)

N, x = [int(x) for x in input().strip().split()]
an = sorted([int(a) for a in input().strip().split()])
cumsum = 0
for i, a in enumerate(an, start=1):
  cumsum += a
  if cumsum > x:
    break
print(i)

N, x = [int(x) for x in input().strip().split()]
an = sorted([int(a) for a in input().strip().split()])
cumsum = 0
ans = 0
for i, a in enumerate(an, start=1):
  cumsum += a
  if cumsum > x:
    break
  ans = i
else:
  if cumsum != 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())
ls = sorted(list(map(int, input().split())))
ans = 0

for i in range(n):
    if x >= ls[i]:
        x -= ls[i]
        ans += 1
print(ans)

n,x = map(int, input().split())
ls = sorted(list(map(int, input().split())))
ans = 0

for i in range(n):
    if x >= ls[i] or x == ls[i]:
        x -= ls[i]
        ans += 1
    else:
        break
print(ans)

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

ans = 0
for i in range(n-1):
    if l[i] <= x:
        x -= l[i]
        ans += 1
else:
    if l[-1] == 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())
a = list(map(int,input().split()))
aa = sorted(a)
nokori = x
cnt = 0
for i in range(n):
         if nokori >= a[i]:
                  cnt +=1
                  nokori = nokori - a[i]
print(cnt)


n,x = map(int,input().split())
a = list(map(int,input().split()))
aa = sorted(a)
nokori = x
cnt = 0
if x > sum(a):
         print(n-1)
else:
         for i in range(n):
                  if nokori >= aa[i]:
                           cnt +=1
                           nokori = nokori - aa[i]
         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()))
sort(a)
for i in range(n):
  x-=a[i]
  if(x<0):
    break
if(x!=0):
  print(i)
else:
  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):
    break
if(x!=0):
  print(i)
else:
  print(n)

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):
N, x = map(int, input().split())
a = sorted([int(i) for i in input().split()])
ans = 0

i = 0
while i < N and 0 < x:
    v = a[i]
    if x - v >= 0:
        x = x - v
        ans += 1
    i += 1

print(ans)

N, x = map(int, input().split())
a = sorted([int(i) for i in input().split()])
b = []
for i, v in enumerate(a):
    if i != N - 1:
        c = min(v, x)
    elif x > v:
        c = x
    else:
        c = min(v, x)
    b.append(c)
    x -= c
ans = 0
for i,j in zip(a,b):
    if i == j:
        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 = sorted(a)
count = 0
for i in a:
    print(f"{i},{x}")
    if x - i >= 0:
        x -= i
        count += 1
    else:
        break
if x != 0:
    count -= 1 if count == n else 0
print(count)

n, x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
print(a)
count = 0
for i in a:
    print(f"{i},{x}")
    if x - i >= 0:
        x -= i
        count += 1
    else:
        break
if x != 0:
    count -= 1 if count == n else 0
print(count)

n, x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
print(a)
count = 0
for i in a:
    print(f"{i},{x}")
    if x - i >= 0:
        x -= i
        count += 1
    else:
        break
print(count)
if x != 0:
    count -= 1 if count == n else 0
print(count)

n, x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
count = 0
for i in a:
    if x - i >= 0:
        x -= i
        count += 1
    else:
        break
if x != 0:
    count -= 1 if count == n else 0
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 = sorted(map(int, input().split()))
      
count=0
for i in range(N):
  if x>=a[i]:
  	x=x-a[i]
  	count+=1
  
print(count)

N, x = map(int, input().split())
a = sorted(map(int, input().split()))
      
count=0
for i in range(N):
  x=x-a[i]
  if x>=0:
    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):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

@jit
def main(n, x, a):
  cnt = 0
  for i in a:
    x -= i
    if x <= 0:
      break
    elif i == a[-1] and x > 0:
      break
    cnt += 1
  return cnt

n, x = map(int, readline().split())
a = np.sort(np.array(readline().split(), np.int64))
print(main(n, x, a))


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np


def main(n, x, a):
  cnt = 0
  for j, i in enumerate(a):
    x -= i
    if x < 0:
      break
    elif j == n-1 and x > 0:
      break
    cnt += 1
  return cnt

n, x = map(int, readline().split())
a = np.sort(np.array(readline().split(), np.int64))
print(main(n, x, a))


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):
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:
    ans += 1
    X -= A[i]
  else:
    break
    
print(ans)

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

A.sort()

ans = 0

fl = True
for i in range(N):
  if A[i] <= X:
    ans += 1
    X -= A[i]
  else:
    fl = False
    break
    
if fl 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):
# -*- coding: utf-8 -*-

n, x = map(int, input().split())
sa = input().split()
a = []

for s in sa:
    a.append(int(s))

a = sorted(a)

ans = 0
sum = 0
for i in a:
    sum += i
    if sum > x:
        break
    ans += 1

print(ans)


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

n, x = map(int, input().split())
sa = input().split()
a = []

for s in sa:
    a.append(int(s))

a = sorted(a)

ans = 0
sum = 0
dif = x
for i in a:
    sum += i
    dif -= i
    if sum > x:
        break
    ans += 1

if dif > 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):
n, x = map(int, input().split())
a = map(int, input().split())
num = len(a)
a.sort(reverse=True)
for i in range(num):
    x -= a.pop()
    if x < 0:
        print(i)
        exit()
    if x == 0:
        print(i + 1)
        exit()
print(num - 1)

n, x = map(int, input().split())
a = list(map(int, input().split()))
num = len(a)
a.sort(reverse=True)
for i in range(num):
    x -= a.pop()
    if x < 0:
        print(i)
        exit()
    if x == 0:
        print(i + 1)
        exit()
print(num - 1)

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):
NX = input()
NX = NX.split(' ')
N = int(NX[0])
x = int(NX[1])
A = input()
A = list(map(int, A.split(' ')))
sorted_a = sorted(A)
s = 0

cum_sum = [0] * (len(sorted_a))
for i, a in enumerate(sorted_a):
    s = s + a
    cum_sum[i] = s

for i, s in enumerate(cum_sum):
    if s > x:
        print(i)
        break

if i == len(cum_sum)-1:
    print(i+1)

NX = input()
NX = NX.split(' ')
N = int(NX[0])
x = int(NX[1])
A = input()
A = list(map(int, A.split(' ')))
sorted_a = sorted(A)
s = 0

cum_sum = [0] * (len(sorted_a))
for i, a in enumerate(sorted_a):
    s = s + a
    cum_sum[i] = s

for i, s in enumerate(cum_sum):
    if s > x:
        print(i)
        break

if i == len(cum_sum)-1 and s == x:
    print(i+1)

NX = input()
NX = NX.split(' ')
N = int(NX[0])
x = int(NX[1])
A = input()
A = list(map(int, A.split(' ')))
sorted_a = sorted(A)
s = 0

cum_sum = [0] * (len(sorted_a))
for i, a in enumerate(sorted_a):
    s = s + a
    cum_sum[i] = s

checker = True
for i, s in enumerate(cum_sum):
    if s == x:
        print(i+1)
        checker = False
        break
    elif s >= x:
        print(i)
        checker = False
        break

if checker:
    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,x = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort()
count = 0
for i in range(n):
    if a_list[i] <= x:
        count += 1
        x = x-a_list[i]
    else:
        break
print(count)

n,x = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort()
count = 0
for i in range(n):
    x = x - a_list[i]
    count += 1
    if x <= 0:
        break


if x == 0:
    print(count)
else:
    print(count-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()
ans = 0
for i in range(n):
    if 0 <= x-a[i]:
        x = x-a[i]
        ans +=1
    
print(ans)


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


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



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

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

if ans == n and X >0 :
    ans -=1     
       
    
print(ans)



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):
# AGC 027 A
N,X =map(int,input().split())
A =[int(j) for j in input().split()]
A.sort()
cnt=0
for a in A:
    if X - a >=0:
        X-=a
        cnt+=1
print(cnt)

N,X= map(int,input().split())
A = [int(a) for a in input().split()]
A.sort()

tmp = 0
ans = 0

for a in A:
    tmp+=a
    if tmp<=X:
        ans+=1
if ans==N and tmp<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):
n,x=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
a.sort()
ans=0
for i in range(n):
    x-=a[i]
    if x<0:
        ans=i
        break
if x>=0:
    ans=n
print(ans)

n,x=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
a.sort()
ans=0
for i in range(n):
    x-=a[i]
    print(x)
    if x<0:
        ans=i
        break
print(ans)

n,x=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
a.sort()
ans=0
for i in range(n):
    x-=a[i]
    if x<0:
        ans=i
        break
print(ans)

n,x=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
a.sort()
ans=0
for i in range(n):
    x-=a[i]
    if x<0:
        ans=i
        break
print(ans)

n,x=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
a.sort()
ans=0
for i in range(n):
    x-=a[i]
    if x<0:
        ans=i
        break
if x==0:
    ans=n
elif x>0:
    ans=n-1
print(ans)

Verdicts: 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()))
a.sort()
count = 0
p = x

for i in a:
  if x - i >= 0:
    x -= i
    count += 1
if x > 0 and count != 0 and p >= a.sum() :
  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
if x > 0 and count != 0  and x > sum(a):
  count -= 1
print(count)

N, x = map(int, input().split())
a = list(map(int, input().split()))
p = x
a.sort()
count = 0

for i in a:
  if x - i >= 0:
    x -= i
    count += 1
if x > 0 and count != 0  and p > sum(a):
  count -= 1
print(count)

Verdicts: Runtime Error

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 x - a[i] < 0:
        break
    cnt += 1
    x -= a[i]
if x < 0:
    cnt -= 1
    
print(cnt)

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

a.sort()

cnt = 0
for i in range(N):
    if x - a[i] < 0:
        break
    cnt += 1
    x -= a[i]

print(cnt)

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

a.sort()

cnt = 0
for i in range(N):
    if x - a[i] >= 0:
        cnt += 1    
    x -= a[i]

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

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


a = sorted(a)

leftCandy = 0
childrenCnt = 0
for i in range(len(a)):
  leftCandy = x - a[i]
  if leftCandy >= 0:
    childrenCnt += 1

print(childrenCnt)

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


a = sorted(a)

leftCandy = 0
childrenCnt = 0
for i in range(len(a)):
  leftCandy = x - a[i]
  if leftCandy >= 0:
    childrenCnt += 1

print(childrenCnt)

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


a = sorted(a)

leftCandy = x
childrenCnt = 0
for i in range(len(a)):
  leftCandy -= a[i]
  if leftCandy >= 0:
    childrenCnt += 1

if leftCandy > 0:
  childrenCnt -= 1

print(childrenCnt)





Verdicts: Wrong Answer

Wrong Answer

Accepted