Problem:


Score : 200 points

Problem Statement

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.

Constraints

All values in input are integers.

2 \leq N \leq 100

1 \leq x \leq 10^9

1 \leq a_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N x
a_1 a_2 ... a_N

Output

Print the maximum possible number of happy children.

Sample Input 1

3 70
20 30 10

Sample Output 1

2

One optimal way to distribute sweets is (20, 30, 20).

Sample Input 2

3 10
20 30 10

Sample Output 2

1

The optimal way to distribute sweets is (0, 0, 10).

Sample Input 3

4 1111
1 10 100 1000

Sample Output 3

4

The optimal way to distribute sweets is (1, 10, 100, 1000).

Sample Input 4

2 10
20 20

Sample Output 4

0

No children will be happy, no matter how the sweets are distributed.



Sample input:
3 70
20 30 10


Sample output:
2

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC27 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,x = LI()
a = LI()
a.sort()
ans = 0
for i in range(n):
    if a[i] <= x:
        x -= a[i]
        ans += 1
if x > 0 and ans > 0:
    print(ans - 1)
elif x > 0 and ans == 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC27 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,x = LI()
a = LI()
a.sort()
ans = 0
for i in range(n):
    if a[i] <= x:
        x -= a[i]
        ans += 1
    else:
        break
if x > 0 and ans > 0:
    print(ans - 1)
elif x > 0 and ans == 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

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

a_s = input().split()
for i in range(N):
  a_s[i] = int(a_s[i])
  
a_s = sorted(a_s)

ans = 0
sum_ = 0
for i in range(N):
  if sum_ + a_s[i] <= x:
    sum_ += a_s[i]
    ans += 1
  else:
    break
print(ans)

Submission status: Wrong Answer

Solution code:
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-1)
  else:
    print(c)
    break

Submission status: Wrong Answer

Solution code:
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

Submission status: Wrong Answer

Solution code:
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
if x>0:
	ans-=1
if ans==-1:
	ans=0
print(ans)

Submission status: Wrong Answer

Solution code:
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]
if x>0:
	ans-=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0

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

print(cnt)

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split(" "))
children = list(map(int, input().split(" ")))

children.sort()
if children[0] > x:
  print(0)
  exit()
  
count = 0
for i in range(n):
  x -= children[i]
  if x == 0:
    count += 1
    break
  elif x > 0:
    count += 1
  else:
    break
if x != 0:
  count -= 1
print(count)

Submission status: Wrong Answer

Solution code:
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
count = 0

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
count=0
sum_a=0
for i in a:
    sum_a+=i
    if x>=sum_a:
        count+=1
else:
    print(count)

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
count=0
sum_a=0
for i in a:
    if x>sum_a:
        sum_a+=i
        count+=1
else:
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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:
		pass
if x>0:
	cnt -=1
print(cnt)

Submission status: Wrong Answer

Solution code:
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 x>0:
	cnt -=1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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 x>0:
	cnt -= 1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, x = map(int, input().split())
        a = list(map(int, input().split()))

        a.sort()
        ans = 0
        for child in a:
            x -= child
            if x == 0:
                ans += 1
                break
            elif x < 0:
                break
            else:
                ans += 1
        if x != 0:
            ans -= 1
        print(min(0, ans))


if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, x = map(int, input().split())
        a = list(map(int, input().split()))

        a.sort()
        ans = 0
        for child in a:
            x -= child
            if x <= 0:
                break
            else:
                ans += 1
        if x != 0:
            ans -= 1
        print(ans)


if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

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

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


count = 0

for y in a:
    ama = x -y
    if ama >=0:
        count += 1
        
if sum(a) >= x:
    print(count)
elif count == 0:
    print(0)
else :
    print(count-1)

Submission status: Wrong Answer

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

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


count = 0

for y in a:
    ama = x -y
    if ama >=0:
        count += 1

print(count)

Submission status: Wrong Answer

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

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

count = 0

for y in a:
    ama = x -y
    if ama >=0:
        count += 1

if count == 0:
    print(0)

else:
    print(count) if sum(a) == x else print(count-1)

Submission status: Wrong Answer

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

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

count = 0

for y in a:
    ama = x -y
    if ama >0:
        count += 1

if count == 0:
    print(0)

else:
    print(count) if sum(a) == x else print(count-1)

Submission status: Wrong Answer

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

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

count = 0

for y in a:
    ama = x -y
    if ama >0:
        count += 1
        
        
print(count) if sum(a) == x else print(count-1)

Submission status: Wrong Answer

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

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

count = 0

for y in a:
    ama = x -y
    if ama >=0:
        count += 1


print(count) if a[-1] == ama else print(count-1)

Submission status: Wrong Answer

Solution code:
N,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
_=0
ans=0
for i in range(N):
    _+=a[i]
    if _ <= x:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
ls=sorted(list(map(int,input().split())))
count=0

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

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
ls=sorted(list(map(int,input().split())))
count=0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N, x = map(int, sys.stdin.readline().rstrip().split())
aa = sorted(list(map(int, sys.stdin.readline().rstrip().split())))
cnt = 0
for a in aa:
    if a == aa[-1]:
        if a == x:
            cnt += 1
    else:
        if a <= x:
            cnt += 1
            x -= a
        else:
            break
print(cnt)

Submission status: Wrong Answer

Solution code:
n,x = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

array.sort()

cnt = 0
for i in range(n):
  x -= array[i]
  if x >= 0:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist

n, x = [ int(v) for v in input().split() ]
candy_list = sorted([ int(v) for v in input().split() ])
candy_list_2 = cumsum(candy_list)

if sum(candy_list) <= x:
    print(n)
else:
    for i in range(n):
        if candy_list_2[i] > x:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int, x: int, a: "List[int]"):
    a.sort()
    res = 0
    xx = x
    for i in range(N):
        if x >= a[i]:
            res += 1
            x -= a[i]
    if x > 0 and sum(a) <= xx:
        print(res - 1)
    elif x > 0 and sum(a) > xx:
        print(0)
    else:
        print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, x, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
import bisect


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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc027/tasks/agc027_a

import bisect


n, x = map(int, input().split())
a = list(sorted(map(int, input().split())))
acc = [0 for i in range(n)]
acc[0] = a[0]
for i in range(1, n):
    acc[i] += a[i - 1] + a[i]
index = bisect.bisect_right(acc, x)
print(index)

Submission status: Wrong Answer

Solution code:
import bisect


n, x = map(int, input().split())
a = list(sorted(map(int, input().split())))
acc = [0 for i in range(n)]
acc[0] = a[0]
for i in range(1, n):
    acc[i] += a[i - 1] + a[i]
index = bisect.bisect_left(acc, x)
print(index)

Submission status: Wrong Answer

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

A.sort()
ans = 0
for a in A:
    if x < a:
        break
    x -= a
    ans += 1
if x > 0:
    ans -= 1
ans = max(0, ans)
print(ans)

Submission status: Wrong Answer

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

A.sort()

temp = 0
for i in range(N):
    temp += A[i]
    if temp > X:
        print(i)
        exit()

print(N)

Submission status: Wrong Answer

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

a.sort()
for i in a:
  x -= i
  b += 1
  if x == 0:
    break
  elif x < 0:
    b -= 1
    break
  elif x > 0 and i == max(a):
    b -= 1
    break
    
print(b)

Submission status: Wrong Answer

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

a.sort()
for i in a:
  x -= i
  b += 1
  if x == 0:
    break
  elif x < 0:
    b -= 1
    break
  elif x > 0 and i == max(a):
    b -= 1
print(b)

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
a = [int(e) for e in input().split()]
a.sort()
result = 0
for i in a:
  x -= i
  if x < 0:
    break
  result += 1
if x != 0:
  result -= 1
print(result)

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
a = [int(e) for e in input().split()]
a.sort()
result = 0
for i in a:
  x -= i
  if x < 0:
    break
  result += 1
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from bisect import bisect
 
n, x = map(int, input().split())
arr = list(map(int, input().split()))
 
arr.sort()
sum_arr = list(accumulate(arr))
 
idx = bisect(arr, x)
 
if idx == n and sum_arr[n - 1] != x:
    idx -= 1

print(idx)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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
if x>0:
  print(ans-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
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
if x!=0:
  print(ans-1)
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from bisect import bisect

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

arr.sort()
sum_arr = list(accumulate(arr))

idx = bisect(arr, x)

if idx == n and sum_arr[n - 1] != x:
    idx -= 1

print(idx)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from bisect import bisect

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

arr.sort()
sum_arr = list(accumulate(arr))

idx = bisect(arr, x)
print(idx)

Submission status: Wrong Answer

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

a.sort()

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

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

Submission status: Wrong Answer

Solution code:
# AGC027A - Candy Distribution Again
# greedy algorithm
from itertools import accumulate


def main():
    # maximize the number of proper distribution -> begin with small values
    n, x = tuple(map(int, input().rstrip().split()))
    A = sorted(map(int, input().rstrip().split()))
    ans = sum(i <= x for i in accumulate(A))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AGC027A - Candy Distribution Again
# greedy algorithm
from bisect import bisect
from itertools import accumulate


def main():
    n, x = tuple(map(int, input().rstrip().split()))
    A = sorted(map(int, input().rstrip().split()))
    ac = list(accumulate(A))
    ans = bisect(ac, x)
    flg = x in ac
    print(ans if flg else max(0, ans - 1))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0

a.sort()

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

print(N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
al=list(map(int,input().split()))
al=sorted(al)
ans=0
for a in al:
    if a>x:
        break
    x-=a
    ans+=1
if x>0 and ans>0:
    ans-=1
print(ans)

Submission status: Wrong Answer

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

a.sort()
remain = 0

for i in range(len(a)):
    remain = x - a[i]
    if sum(a) == x:
        while n > 0:
            count += 1
            n -= 1
        continue
    if remain >= 0 and i != len(a)-1:
        count += 1
    else:
        break

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
e = 0
for i in c:
    d = min(i, b)
    if d == i:
        e += 1
        b -= i
    else:
        break

if b != 0:
    e = max(e-1, 0)
print(e)
exit()

Submission status: Wrong Answer

Solution code:
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
    
n,x=MI()
a=LI()
a.sort()
y=x
ans,s=0,0
for i in range(n):
    s+=a[i]
    if s>x:
        break
    else:
        if i<n-1:
            ans+=1
        elif x-s==a[i]:
            ans+=1
            
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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 and cnt:
    cnt -= 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
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 and cnt:
    cnt -= 1
    
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

a.sort()


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

if now==0:
    print(cnt)
else:
    print(cnt-1)

Submission status: Wrong Answer

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

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

a.sort()


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

print(cnt)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, x: int, a: "List[int]"):
    ans = 0
    a.sort()
    for i in a:
        if(x-i >= 0):
            ans += 1
            x -= i
        else:
            break

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


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, x, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
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 and x>0:
  i-=1
elif i==n and x==0:
  i+=1
print(i)

Submission status: Wrong Answer

Solution code:
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 and x>0:
  i-=1
print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, x = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in l:
    x = x - i   #i個あげる
    if x >= 0:   #本当にあげれたか？
        cnt += 1
    else:
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
num = 0
if sum(a) < x:
    print(n-1)
elif a[-1] > x:
    print(0)
else:
    while x > 0:
        x = x - a.pop()
        num += 1
    print(num)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,x = map(int,input().split())
A = np.array(input().split(), dtype = np.int64)
A.sort()
np.cumsum(A, out = A)
answer = (A <= x).sum()
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,x = map(int,input().split())
A = np.array(input().split(), dtype = np.int64)
A.sort()
A = A.cumsum()
answer = (A <= x).sum()
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,x = map(int,input().split())
A = np.array(input().split(), dtype = np.int64)
A.sort()
np.cumsum(A, out = A)
answer = (A <= x).sum()
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,x = map(int,input().split())
A = np.array(input().split(), dtype = np.int64)
A.sort()
A = A.cumsum()
np.cumsum(A, out = A)
answer = (A <= x).sum()
print(answer)