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

n,x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
count = 0
s = 0
for i in range(n):
    if i == n-1:
        if x == a[i]:
            count += 1
    else:
        s += a[i]
        if x > a[i]:
            x -= a[i]
            count += 1
        elif x < a[i]:
            break
        else:
            count += 1
            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):
nx = list(map(int,input().split(' ')))
a = list(map(int,input().split(' ')))
a.sort(reverse=True)

#print(a)
y = 0
okashi= nx[1]
for i in a:
  if  okashi>= i:
    okashi -=i
    y+=1

#print(okashi)    
if y>=1 &okashi>0:
   y-=1
    
  
print(y)  

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

#print(a)
y = 0
okashi= nx[1]
for i in a:
  if  okashi>= i:
    okashi -=i
    y+=1

#print(okashi)    
if y>=1 &okashi>0:
   y-=1
    
  
print(y)  
  
  
  
  

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


a_sort = sorted(a)
#print(a_sort)
manzoku =0
flag = 0
for n,i in enumerate(a_sort):
    if x>=i:
      x-=i
      #print(x)
      manzoku+=1
#      print(x,i)
    elif x<i:
      flag =1
      
    

if  flag:
    print(manzoku)
elif flag==0 and(x>0) and (manzoku>0):
    print((manzoku)-1)
else:
    print(manzoku)


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 = int(input())
x = int(input())
y=x
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = y
    ans += 1
if x>0:
    ans = ans - 1
print(ans)

N = int(input())
x = int(input())
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
cage = sorted(cage)
ans=0

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

if cage[0]>x:
    ans=0
if x != 0:
    ans -= 1
print(ans)

N = int(input())
x = int(input())
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = "no"
    ans += 1
if x>0:
    ans = ans - 1
print(ans)

N = int(input())
x = int(input())
y=x
cage = list(map(int,input().split()))
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = y
    ans += 1
if x>0:
    ans = ans - 1
print(ans)

N = int(input())
x = int(input())
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = "no"
    ans += 1
if x>0:
    ans = ans - 1
print(ans)
print(x,cage)

N, x = map(int, input().split())
cage = sorted([int(i) for i in input().split()])

ans=0

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

if cage[0]>x:
    ans=0
if x>0:
    ans = ans - 1
print(ans)

N = int(input())
x = int(input())
y=x
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = y
    ans += 1
if x>0:
    ans = ans - 1
print(ans)

N, x = map(int, input().split())
A = list(map(int, input().split()))
 
x_tmp = x
for i, Ai in enumerate(sorted(A)):
    x_tmp -= Ai
    if x_tmp == 0:
        ans = i + 1
        break
    elif x_tmp < 0:
        ans = i
        break
    else: continue
else: ans = i
 
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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):
n,m=map(int,input().split())
ans=0
ch=list(map(int,input().split()))
ch.sort()
sum=0
i=0
while sum<m:
  sum+=ch[ans]
  ans+=1
  if sum > m:
    ans-=1
    break
print(ans)

n,m=map(int,input().split())
ans=0
ch=list(map(int,input().split()))
ch.sort()
sum=0
i=0
while sum<m and ans!=n:
  sum+=ch[ans]
  ans+=1
  if sum > m:
    ans-=1
    break
print(ans)


n,m=map(int,input().split())
ans=0
ch=list(map(int,input().split()))
ch.sort()
if m>=sum(ch):
  print(n)
else:
  sum=0
  i=0
  while sum<m and ans!=n:
    sum+=ch[ans]
    ans+=1
    if sum > m:
      ans-=1
      break
  print(ans)


n,m=map(int,input().split())
ans=0
ch=list(map(int,input().split()))
ch.sort()
if m>sum(ch):
  print(n-1)
else:
  sum=0
  i=0
  while sum<m and ans!=n:
    sum+=ch[ans]
    ans+=1
    if sum > m:
      ans-=1
      break
  print(ans)


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

def func():
    cummulative_sum = 0
    for index, value in enumerate(A):
        cummulative_sum += value
        if cummulative_sum > x:
            index
        
    if cummulative_sum != x:
        return len(A) - 1
    else:
        return len(A)
    
func()

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

def func():
    cummulative_sum = 0
    for index, value in enumerate(A):
        cummulative_sum += value
        if cummulative_sum > x:
            return index

    if cummulative_sum != x:
        return len(A) - 1
    else:
        return len(A)

ans = func()

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

n,x = map(int,input().split())
a = sorted(map(int,input().split()))
c=0
for i in a:
    if x<i:
        break
    x-=i
    c+=1
else:
    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):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,x=i2()
a=intl()
a.sort()
b=0
for i in range(n):
	x-=a[i]
	if x>=0:
		b+=1
	if x<0:
		break
print(b)

def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,x=i2()
a=intl()
a.sort()
b=0
for i in range(n):
	x-=a[i]
	if i<n-1:
		if x>=0:
			b+=1
		elif x<0:
			break
	elif i==n-1:
		if x==0:
			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())
a=list(map(int,input().split() for i in range(n)))
a_sort=sorted(a)
count=0
sum=0
for i in a_sort:
    while sum+i<=x:
        sum=sum+i
        count+=1
    else:
        break
print(count)


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

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


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

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

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

print(cnt)

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

print(cnt)

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

print(cnt)

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()
c = 0
rx = x
for i in range(N):
  if a[i] > rx:
    print(c)
    exit()
  c += 1
  rx -= a[i]
print(N)

N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
c = 0
rx = x
for i in range(N):
  if a[i] > rx:
    print(c)
    exit()
print(N)

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

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

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()
c=0
for i in range(len(a)+1):
  if x>0 and x>a[i]:
    x-=a[i]
    c+=1
  else:
    print(c)
    break

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

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

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


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

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

Verdicts: Runtime Error

Runtime Error

Wrong Answer

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


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


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


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


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

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


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

a.sort()

ans = 0
for ai in a:
    if ai <= amount:
        amount -= ai
        ans += 1

print(ans)


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

a.sort()

ans = 0
for ai in a:
    if ai <= amount:
        amount -= ai
        ans += 1

if amount > 0 and ans == 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):

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

    a = sorted(a)
    ans = 0
    tmp = 0
    for i in a:
        tmp += i
        if tmp <= x:
            ans+=1

    print(ans)




if __name__ == "__main__":
        main()



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

    a = sorted(a)
    ans = 0
    tmp = 0
    for i in a:
        tmp += i
        if tmp <= x:
            ans+=1

    if n == ans:
        if sum(a) != x:
            ans-=1

    print(ans)




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):
def main():
    N,x=[int(i) for i in input().split()]
    a=input().split()
    k=0
    while True:
        if x>=int(min(a)):
            x=x-int(min(a))
            a.remove(min(a))
            k+=1
            if len(a)==0:
                break
        else:
            break
    print(k)
main()


from itertools import accumulate
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a_acc = list(accumulate(a))
for i in range(n):
    if a_acc[i] > x:
        print(i)
        exit()
if sum(a) == x:
    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())
li = sorted(list(map(int, input().split())))

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

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

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

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


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()))
AA=sorted(A)
ans=0
for a in A:
  if x>=a:
    x-=a
    ans+=1
  else:
    break
print(ans)

N,x=map(int,input().split())
A=list(map(int,input().split()))
AA=sorted(A)
ans=0
for i in range(N):
  if x>=AA[i]:
    x-=AA[i]
    ans+=1
  else:
    x=0
    break
if 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):
from bisect import bisect
from itertools import accumulate
n,x,*a=map(int,open(0).read().split())
b=list(accumulate(sorted(a)))
print(bisect(b,x))

from bisect import bisect
from itertools import accumulate
n,x,*a=map(int,open(0).read().split())
b=list(accumulate(sorted(a)))
print(bisect(b,x)-(b[-1]<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()))
cnt = 0
a.sort()
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()))
cnt = 0
a.sort()
for i in range(N):
    if a[i]<=x:
        x -= a[i]
        cnt += 1
    else:
        break
if (x!=0)and(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):
#22
N,x = map(int,input().split())
a = list(map(int,input().split()))
cou =0

a.sort()

for i in a:
    if i >x:
        break
    cou +=1
    x -= i
    
while x>0:
    for i in a:
        if x%i ==0:
            cou -=1
            break
        while x > i:
            x-=i
        cou -= 1
print(cou)
    

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

a.sort()

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

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

a.sort()

if sum(a) ==x:
    print(N)
elif sum(a) < x:
    print(N-1)
else:
    for i in range(N):
        if sum(a[0:i+1]) >x:
            print(i)
            break
    

Verdicts: Time Limit Exceeded

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 math


# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N, x = invr()

a = inlist()
a = sorted(a)
c = 0
for i in a:
    if i <= x:
        c += 1
        x -= i
print(c)


import math


# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N, x = invr()

a = inlist()
a = sorted(a)
c = 0
for i in a:
    if i <= x:
        c += 1
        x -= i
    else:
        x = 0

if x > 0 and c > 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 = list(map(int, input().split()))
a.sort()
sum = 0
people = 0

if x == sum(a):
    print(n)
elif x > sum(a):
    print(n-1)
else:
    for i in a:
        sum += i
        people += 1
        if sum > x:
            print(people-1)
            break

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


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

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

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

N, x = map(int, input().split())
a = sorted(map(int, input().split()))
cnt = 0

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

print(cnt if x <= 0 else cnt-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):
N,x = map(int, input().split())
lis = [int(i) for i in input().split()]
lis.sort()
s = 0
ans = 0
for nums in lis:
  if x >= nums:
    x += -nums
    ans += 1
print(ans)
  

N,x = map(int, input().split())
lis = [int(i) for i in input().split()]
lis.sort()
s = 0
ans = 0
for nums in lis:
  if x >= nums:
    x += -nums
    ans += 1
if ans == N and x != 0:
  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):
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

count = 0
for ai in a:
    if ai <= x:
        x -= ai
        count += 1
    else:
        break


if count == N and x > 0:
    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 ai <= x:
        x -= ai
        count += 1
    else:
        break


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

(n, x) = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
sum = 0
count = 0
for i in a:
    sum += i
    if sum > x:
        break
    count += 1
print(count)

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


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

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


al.sort()

count=0
acc = 0
for ai in al:
    acc += ai
    if acc > x:
        break
    count+=1

print(count)



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

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


al.sort()

count=0
acc = 0
for ai in al:
    acc += ai
    if acc > x:
        break
    count+=1
if acc < 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()))
ans = 0
A.sort()
for a in A:
  if x >= a:
    x -= a
    ans += 1
print(ans)
         

N, x = map(int, input().split())
tmp = x
A = list(map(int, input().split()))
ans = 0
A.sort()
for a in A:
  if x >= a:
    x -= a
    ans += 1
if x > sum(A):
  ans -= 1
print(ans)
         


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

A.sort()
ans = 0

for i in A:
    x -= a
    if x >= 0:
        ans += 1
    else:
        break
if x > 0:
    ans -= 1
print(ans)



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

A.sort()
ans = []
for i in A:
	if x < i:
		break
	ans += 1
	x -= i

else:
	if x > 0:
		ans -= 1
print(ans)



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

A.sort()
ans = []
for i in A:
	if x < i:
		break
	ans += 1
	x -= i
	else:
		break

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


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

A.sort()
ans = []
for i in A:
	ans.append(i)
	x -= i
	#print(ans, x)
	if x <= 0:
		break

print(len(ans))

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

A.sort()
ans = []
for i in A:
	if x < i:
		break
	ans += 1
	x -= i
else:
	break

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


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

A.sort()
ans = []
for i in A:
	x -= i
	#print(ans, x)
	if x >= 0:
		ans.append(i)
	else:
		break
	
if x > 0:
	print(len(ans)-1)
else:
	print(len(ans))

Verdicts: Runtime Error

Runtime Error

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

list_a.sort()
total = sum(list_a)
if x < list_a[0] :
    print(0)
    exit()

ans = 0

for i in range(N) :
    if list_a[i] <= x :
        x -= list_a[i]
        ans += 1

print(ans)


N, x = map(int, input().split())
list_a = [int(x) for x in input().split()]

list_a.sort()
total = sum(list_a)
if x < list_a[0] :
    print(0)
    exit()
if x > total :
    print(ans-1)
    exit()
ans = 0

for i in range(N) :
    if list_a[i] <= x :
        x -= list_a[i]
        ans += 1

print(ans)


N, x = map(int, input().split())
list_a = [int(x) for x in input().split()]

list_a.sort()
total = sum(list_a)
if x < list_a[0] :
    print(0)
    exit()
if x > total :
    print(len(list_a)-1)
    exit()
ans = 0

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

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

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 = list(map(int, input().split()))
ais = list(map(int, input().split()))
s = 0
cnt = 0
ais.sort()
for ai in ais:
    if(s+ai>=x):
        break
    else:
        s += ai
        cnt += 1
print(cnt)

N, x = list(map(int, input().split()))
ais = list(map(int, input().split()))
s = 0
cnt = 0
ais.sort()
for ai in ais:
    if(s+ai>x):
        break
    else:
        s += ai
        cnt += 1
print(cnt)

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

s = 0
cnt = 0
ais.sort()

for ai in ais:
    if(s+ai>x):
        break
    else:
        s += ai
        cnt += 1

if((cnt==N) & (s < x)):
    cnt -= 1

print(cnt)

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=[int(i) for i in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt=0
for k in range(N):
	if x-a[k] >= 0:
		x -= a[k]
		cnt += 1
		if k==N and x >0:
			cnt -=1
	else:
		if k==N:
			cnt -=1
		break
print(cnt)

N,x=[int(i) for i in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt=0
for k in range(N):
	if x-a[k] >= 0:
		x -= a[k]
		cnt += 1
	else:
		break
print(cnt)

N,x=[int(i) for i in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt=0
for k in range(N):
	if x-a[k] >= 0:
		x -= a[k]
		cnt += 1
		if k==N and x >0:
			cnt -=1
	else:
		break
print(cnt)

N,x=[int(i) for i in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt=0
for k in range(N):
	if x-a[k] >= 0:
		x -= a[k]
		cnt += 1
		if k==N and x >0:
			cnt -=1
	else:
		if k==N and x>0:
			cnt -=1
		break
print(cnt)

N,x=[int(i) for i in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt=0
for k in range(N):
	if x-a[k] >= 0:	
		x -= a[k]
		cnt += 1
	else:
		break
	if k==N and x >0:
		cnt -=1
print(cnt)

N,x=[int(i) for i in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt=0
for k in a:
	x -= k
	if x < 0:
		break
	cnt +=1
if x >0:
	cnt -=1
print(cnt)

Verdicts: 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()))
counter = 0
for i in sorted(a):
  x -= i
  if x < 0:
    print(counter)
  else:
    counter += 1
  if counter == n:
    print(n)

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

n, x = map(int, input( ).split())
a = list(map(int, input().split()))
counter = 0
for i in sorted(a):
  if counter == n and x>0:
    print(n-1)
  elif counter == n and x==0:
    print(n)
  x -= i
  counter += 1
  if x < 0:
    print(counter-1)

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


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

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

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

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

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted