problem_id
stringclasses
100 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
6
806
p03254
s886794202
Accepted
n , x = map(int,input().split()) a = sorted(list(map(int,input().split()))) cnt = 0 if x > sum(a): print(n - 1) exit() for i in range(n): if (x - a[i]) >= 0: x -= a[i] cnt += 1 else: break print(cnt)
p03254
s929457757
Accepted
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)): sum += a[i] if x >= sum: ans += 1 if ans == N: if sum != x: ans -= 1 break else: break print(ans)
p03254
s230108782
Accepted
N,x=map(int,input().split()) a=sorted(map(int,input().split())) c=0 if x>sum(a): print(N-1) exit() while x>0 and c<=N-1: if x-a[c]>=0: x-=a[c] c+=1 else: break print(c)
p03254
s035631099
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) sum_a = sum(a) cnt = 0 a.sort() if x > sum_a: cnt = n - 1 elif x == sum_a: cnt = n else: for i in a: if i <= x: x -= i cnt += 1 else: break print(cnt)
p03254
s972816750
Accepted
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)
p03254
s311711457
Accepted
from typing import SupportsComplex N, x = [int(a) for a in input().split()] a = [int(a) for a in input().split()] a = sorted(a) result = [] for v in a: if x >= v: result.append(v) x -= v else: break if len(result) == 0: print(0) exit() if (x > 0) and (len(result) == len(a)): result[-1] += x if result[-1] != a[len(result)-1]: ans = len(result)-1 else: ans = len(result) print(ans)
p03254
s092458915
Accepted
N, x = list(map(int, input().split())) a = list(map(int, input().split())) result = 0 sorted_a = sorted(a) remain = x for a_i in sorted_a: if remain >= a_i: result += 1 remain -= a_i else: break ### 最後の子供にぴったりのお菓子をあげられなかった if result == N and remain != 0: result -= 1 print(result)
p03254
s913591676
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 if sum(a) == x: ans = n elif x < min(a): ans = 0 else: if sum(a) < x: ans = n - 1 else: a.sort() k = 0 for e in a: k += e if k <= x: ans += 1 else: break print(ans)
p03254
s231410533
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) if sum(a) == x: print(n) elif sum(a) < x: print(n-1) else: a = sorted(a) total = 0 for i in range(n): total += a[i] if total == x: print(i+1) exit() elif total > x: print(i) exit()
p03254
s768966760
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 a = sorted(a) for i in range(n): if a[i] <= x: ans += 1 x -= a[i] if x <= 0: break if x > 0 and ans != 0: ans -= 1 print(ans)
p03254
s707896844
Accepted
import numpy as np N, x = map(int, input().split()) a = np.array(list(map(int, input().split()))) cs = np.sort(a).cumsum() if cs[-1]<x: print(N-1) elif cs[-1]==x: print(N) else: print(np.where(cs<=x)[0].shape[0])
p03254
s705781813
Accepted
N,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() s = x cnt = 0 if s > sum(a): print(N-1) elif (s >= a[0] and s <= sum(a)): for i in range(N): if s >= a[i]: cnt += 1 s -= a[i] print(cnt) else: print(0)
p03254
s487237992
Accepted
n,x = map(int,input().split()) A = list(map(int,input().split())) A.sort() ans = 0 for a in A: x = x - a if x < 0: break ans += 1 if x > 0 and ans > 0: ans -= 1 print(ans)
p03254
s692938017
Accepted
N,x = map(int, input().split()) li = list(map(int, input().split())) li.sort() a = 0 an = 0 while a < N: x -= li[a] if x < 0: break an += 1 a += 1 if x > 0: an -= 1 print(an)
p03254
s720983057
Accepted
n, x = map(int, input().split()) a = list(map(int,input().split())) a.sort() c = 0 while x-a[c] >= 0: x -= a[c] c += 1 if x == 0: break elif c == n: c -= 1 break print(c)
p03254
s022956944
Accepted
import sys input=sys.stdin.readline from bisect import bisect_right import itertools N,X= map(int,input().split()) A=list(map(int,input().split())) A.sort() Acum = list(itertools.accumulate(A)) answer = bisect_right(Acum,X) if answer == N: if Acum[-1] < X: answer -= 1 print(answer)
p03254
s936072339
Accepted
N,X=map(int,input().split()) *A,=map(int,input().split()) A.sort() ans=0 i=0 while X and i<N-1: X-=A[i] if X>=0: ans+=1 else: break i+=1 if i==N-1 and A[i]==X: ans+=1 print(ans)
p03254
s701702837
Accepted
N, x = map(int, input().split()) A = list(map(int, input().split())) A = sorted(A) answer = 0 for i, a in enumerate(A): if a > x: print(answer) exit() if i == N-1: if a != x: print(answer) else: answer += 1 print(answer) else: x -= a answer += 1
p03254
s068215189
Accepted
n, x = map(int, input().split()) A = list(map(int, input().split())) ans = 0 A.sort() for i in range(n): if x > A[i] and i != n - 1: x = x - A[i] ans = ans + 1 elif x == A[i]: ans = ans + 1 break else: break print(ans)
p03254
s489697281
Accepted
n,x=map(int,input().split()) a=sorted(list(map(int,input().split()))) ans=0 for i in a[:-1]: if i<=x: x-=i ans+=1 if a[-1]==x: ans+=1 print(ans)
p03254
s696769034
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = 0 for i in a: x -= i if x >= 0: ans += 1 else: break if x > 0: print(ans - 1) else: print(ans)
p03254
s186887515
Accepted
N,x = map(int,input().split()) a = list(map(int, input().split())) a.sort() s = 0 counter = 0 for i in range(N): if i != N-1: s += a[i] if s <= x: counter += 1 else: break else: if x - s == a[i]: counter += 1 else: break print(counter)
p03254
s396180471
Accepted
N,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() count = 0 if x < a[0]: print(0) exit() for i in range(N): if x >= a[i]: x = x - a[i] count += 1 else: print(count) exit() if x > 0: print(count - 1) else: print(count)
p03254
s143205633
Accepted
N,x = map(int,input().split()) a = list(map(int,input().split())) A = sorted(a) cont = 0 if x > sum(A): print(N-1) else: for i in range(N): if x >= A[i]: x -= A[i] cont += 1 print(cont)
p03254
s844445316
Accepted
N, x = map(int,input().split()) a = list(map(int,input().split())) a.sort() ans = 0 for i in range(N): x -= a[i] if i == N-1: if x == 0: ans += 1 elif x >= 0: ans += 1 print(ans)
p03254
s745030708
Accepted
n,x=map(int,input().split()) a=sorted(list(map(int,input().split()))) c,i=0,0 while(i<n and x>0): if a[i]<=x: x-=a[i] c+=1 else: break if i==n-1 and x!=0: c-=1 i+=1 print(c)
p03254
s624130338
Accepted
N, x = map(int, input().split()) a = sorted(map(int, input().split())) cnt = 0 for i in a: if x >= i: cnt += 1 x -= i else: break else: if x > 0: cnt -= 1 print(cnt)
p03254
s479880101
Accepted
n,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() ans = 0 i = 0 while x >= a[i]: if i == n-1: if a[i] == x: ans+=1 break else: break x -= a[i] i += 1 ans += 1 print(ans)
p03254
s445924035
Accepted
N, x = map(int, input().split()) A = sorted(list(map(int, input().split()))) cnt = 0 for i in range(N): if i == N - 1: if x == A[i]: cnt += 1 x -= A[i] else: if x >= A[i]: cnt += 1 x -= A[i] print(cnt)
p03254
s110368086
Accepted
N,x = map(int,input().split()) A = sorted(map(int,input().split())) S =[0]+[0 for i in range(N)] for i in range(N): S[i+1]=S[i]+A[i] #print(S) if S[i+1]>x: print(i) exit() if S[-1]==x: print(N) else: print(N-1)
p03254
s653752118
Accepted
n, x = map(int, input().split()) aList = list(map(int, input().split())) aList.sort() sums = 0 i = 0 while sums < x and i < n: sums += aList[i] i += 1 i -= 1 if sums == x: i += 1 print(i)
p03254
s534876777
Accepted
n, x = map(int, input().split()) A = sorted(list(map(int, input().split()))) for i in range(n + 1): if sum(A[:i]) > x: print(i - 1) exit() elif sum(A[:i]) == x: print(i) exit() print(n - 1)
p03254
s209579329
Accepted
n,x = map(int,input().split()) a = sorted(list(map(int,input().split()))) now = x for i in range(n): now -= a[i] if now < 0: print(i) exit() elif now == 0: print(i+1) exit() print(n-1)
p03254
s864177367
Accepted
N,x=map(int,input().split(' ')) A=sorted(list(map(int,input().split(' ')))) ans = 0 for i in A: if x >= i: ans += 1 x -=i else: break if x > 0 and ans==N: print(N-1) else: print(ans)
p03254
s812294448
Accepted
N, x = map(int, input().split()) A = list(map(int, input().split())) cnt = 0 for i in range(N): if x < min(A): print(cnt) break elif i == N-1 and x-A[0] > 0: print(N-1) break elif i == N-1 and x-A[0] == 0: print(N) break else: x -= min(A) A.remove(min(A)) cnt += 1
p03254
s308338635
Accepted
n,x=map(int,input().split()) a=list(map(int,input().split())) a.sort() ans,cnt=[0,0] for i in range(n): cnt+=a[i] if cnt>x: break ans+=1 if i==n-1 and cnt!=x: ans-=1 print(ans)
p03254
s166181706
Accepted
n, m = map(int, input().split()) a = sorted(list(map(int,input().split()))) ans = 0 for i in a: if m - i < 0: print(ans) exit() m -= i ans += 1 if m > 0: print(ans-1) else: print(ans)
p03254
s018746803
Accepted
n,x = map(int,input().split()) a = sorted([int(x) for x in input().split()]) ans = 0 for i in range(n): if x >= a[i] and i != n-1: x -= a[i] ans += 1 elif i == n-1: if x == a[i]: ans += 1 print(ans)
p03254
s370389873
Accepted
N , X = map(int,input().split()) A = list(map(int,input().split())) A.sort() a = 0 for i in range(N): a += A[i] if a > X: break if i == N - 1: if a == X: print(i + 1) else: print(i) if i < N - 1: print(i)
p03254
s319877990
Accepted
n, x = map(int,input().split()) a = list(map(int,input().split())) ans = 0 if sum(a) < x: print(n-1) exit() elif sum(a) == x: print(n) exit() else: a = sorted(a) for i in range(n): ans += a[i] if ans > x: print(i) exit()
p03254
s340177726
Accepted
n, x = map(int, input().split()) s = list(map(int, input().split())) s.sort() cnt = 0 for i in range(n): if x >= s[i]: x -= s[i] cnt += 1 else: x = 0 break if x > 0: cnt -= 1 print(cnt)
p03254
s634459329
Accepted
N, x = map(int, input().split()) A = map(int, input().split()) #A = sorted(A, reverse=True) A = sorted(A) tmp = 0 count = 0 for i, a in enumerate(A): if tmp + a > x: break if (i == len(A) -1) and tmp + a < x: break tmp += a count += 1 print(count)
p03254
s190000131
Accepted
n,x = map(int,input().split()) a = list(map(int,input().split())) Slist = sorted(a) cnt = 0 Sum = 0 if x > sum(Slist): print(n-1) exit() for i in range(n): Sum += Slist[i] if x>=Sum: cnt +=1 else: break print(cnt)
p03254
s089319418
Accepted
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)
p03254
s591809711
Accepted
N, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() count = 0 for i in range(len(a)): if i < len(a) - 1 and a[i] <= x: count += 1 x -= a[i] elif i == len(a) - 1 and a[i] == x: count += 1 else: break print(count)
p03254
s925573722
Accepted
# -*- coding: utf-8 -*- N,x = map(int, input().split()) a = list(map(int, input().split())) a_sorted = sorted(a) num = 0 reminder = x for i in range(N): reminder -= a_sorted[i] if reminder>=0: num += 1 else: break if reminder>0: num -= 1 print(num)
p03254
s545106208
Accepted
n,x=map(int,input().split()) a=sorted([int(i)for i in input().split()]) res=0 if sum(a)==x: res=n else: for i in range(n): if sum(a[:i])<=x:res=i print(max(0,res))
p03254
s166805673
Accepted
n,x=map(int,input().split()) a=[0]*n a=list(map(int,input().split())) a=sorted(a) num=0 ans=0 al=x for i in range(n): num+=a[i] al=al-a[i] if (num>x): break if (i==n-1 and num<x): break ans+=1 print(ans)
p03254
s451418914
Accepted
N,x=map(int, input().split()) a=list(map(int, input().split())) a.sort() cnt=0 for b in a: x-=b if x>=0: cnt+=1 else: break if x>0: print(cnt-1) else: print(cnt)
p03254
s360409907
Accepted
N, x = [int(z) for z in input().split()] children = [int(z) for z in input().split()] children.sort() sum = 0 for i in children: sum += i if sum < x: print(N - 1) elif sum == x: print(N) else: cnt = 0 for i in children: if x - i < 0: break else: x -= i cnt += 1 print(cnt)
p03254
s530605082
Accepted
N, x = map(int, input().split()) A = [int(i) for i in input().split()] A = sorted(A) i = 0 while i < N: if A[i] <= x: x -= A[i] i += 1 else: break if i == N and x > 0: i -= 1 print(i)
p03254
s984974885
Accepted
def ii():return int(input()) def iim():return map(int,input().split()) def iil():return list(map(int,input().split())) def ism():return map(str,input().split()) def isl():return list(map(str,input().split())) n,x = iim() A = sorted(iil()) count = 0 for i in A: x -= i count += 1 if x < 0: print(count-1) exit() elif x == 0: print(count) exit() print(count-1)
p03254
s821601203
Accepted
n,x=map(int,input().split()) A=sorted(list(map(int,input().split()))) for i in range(n): if x-A[i]>=0: x=x-A[i] else: print(i) exit() if x==0:print(n) else:print(n-1)
p03254
s541995824
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() if x < a[0]: print(0) exit() if sum(a) < x: print(n - 1) exit() cnt = 0 for i in range(n): if a[i] <= x: cnt += 1 x -= a[i] print(cnt)
p03254
s843309226
Accepted
n,x= list(map(int, input().strip().split())) a= list(map(int, input().strip().split())) a.sort() count=0 f=0 for i in range(n): count+=a[i] if count>x: f=i break if count<x: print(n-1) elif count==x: print(n) else: print(f)
p03254
s421189956
Accepted
n, x = map(int, input().split()) li = sorted(map(int, input().split())) ans = 0 for a in li: if x >= a: x -= a ans += 1 if ans == n and x > 0: ans -= 1 print(ans)
p03254
s170056315
Accepted
n,x,*a=map(int,open(0).read().split()) a.sort() for i in range(n): x-=a[i] if x<0: print(i) break elif x==0: print(i+1) break else: print(n-1)
p03254
s401528759
Accepted
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)
p03254
s536734659
Accepted
N,x=map(int,input().split()) a=sorted(list(map(int,input().split()))) cnt=0 while cnt<=N-1 and x>=a[cnt]: x-=a[cnt] if cnt==N-1 and x!=0: pass else: cnt+=1 print(cnt)
p03254
s774252146
Accepted
N,x = [int(hoge) for hoge in input().split()] A = [int(hoge) for hoge in input().split()] #x個のお菓子を配る。 #和がxを越えないように最も多い数のaを選ぶ A.sort() ans = 0 cur = 0 for a in A: cur += a if cur > x: print(ans) exit() ans += 1 if cur == x:print(N) else:print(ans-1)
p03254
s636594401
Accepted
N,x = map(int, input().split()) A = [int(i) for i in input().split()] """ 「ちょうど」でキャッキャ """ A.sort() from itertools import accumulate A = tuple(accumulate(A)) ans = N - 1 for i,a in enumerate(A): if x > a: pass elif x == a: ans = i + 1 break else: ans = i break print(ans)
p03254
s530724939
Accepted
n,x = map(int,input().split()) a = list(map(int,input().split())) if sum(a) == x: print(n) elif sum(a) < x: print(n-1) else: a.sort() ans = 0 for i in a: if i > x: break else: x -= i ans += 1 print(ans)
p03254
s110929066
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) # box = [] cnt = 0 for i in range(n): x = x - a[i] if(x >= 0): cnt += 1 else: break if(x != 0 and cnt == n): cnt -= 1 print(cnt)
p03254
s000124907
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = 0 for i in a: x-=i if x<0: print(ans) break ans += 1 else: if x==0: print(ans) else: print(ans-1)
p03254
s787337170
Accepted
n, x = map(int, input().split()) a = sorted(list(map(int, input().split()))) count = 0 for i in range(n): x -= a[i] if x>0: count += 1 elif x==0: count += 1 break else : if x>0 : count -= 1 print(count)
p03254
s491205453
Accepted
n, x = map(int, input().split()) A = list(map(int, input().split())) A.sort() ans = 0 for a in A: x -= a if x >= 0: ans += 1 else: break if x > 0: ans -= 1 print(ans)
p03254
s926257370
Accepted
n,x=map(int,input().split()) a=list(map(int, input().split())) ans=0 rest=x target=sorted(a) if sum(target)<x: print(n-1) elif sum(target)==x: print(n) else: for i in range(n): rest-=target[i] if rest<0: ans=i break if rest==0: ans=i+1 break print(ans)
p03254
s908984472
Accepted
n,x = map(int, input().split()) a = sorted(list(map(int, input().split()))) ans = 0 if x<min(a): ans = 0 elif x>sum(a): ans = n-1 else: for i in range(1,n+1): if x>=sum(a[:i]): ans+=1 else: break print(ans)
p03254
s511656915
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() count = 0 for i in range(n): if i == n-1: if x == a[i]: count += 1 elif x >= a[i]: count += 1 x -= a[i] print(count)
p03254
s995782042
Accepted
N, x = map(int, input().split()) a = [int(i) for i in input().split()] res = 0 if x == sum(a): res = N elif x > sum(a): res = N -1 else: a.sort() while x > 0: if x >= a[0]: res += 1 x -= a.pop(0) print(res)
p03254
s220383532
Accepted
n , x = map(int,input().split()) a = list(map(int,input().split())) a.sort() cou = 0 for i in range(n): cou += a[i] if cou == x: print(i + 1) break elif cou > x: print(i) break else: print(n-1)
p03254
s914236802
Accepted
# -*- coding: utf-8 -*- #---------- n,x = list(map(int, input().rstrip().split())) a_list = list(map(int, input().rstrip().split())) #---------- a_list.sort() x_remain=x result = -1 for i in range(n): x_remain -= a_list[i] if x_remain == 0: result = i+1 break if x_remain < 0: result = i break if result == -1 : result = n-1 print(result)
p03254
s989300170
Accepted
n, x = map(int, input().split()) a = [int(x) for x in input().split()] a.sort() ans = 0 for i in range(n): if a[i] <= x: ans += 1 x -= a[i] if i == n-1 and x != 0: ans -= 1 else: break print(ans)
p03254
s071690568
Accepted
n,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() c = 0 i = 0 while(True): if(i >= n - 1): break if(x < a[i]):break c += 1 x -= a[i] i += 1 if(x == a[i]):c += 1 print(c)
p03254
s823967760
Accepted
n,x=map(int,input().split()) A=list(map(int,input().split())) A.sort() ans=0 for a in A[:-1]: x-=a if x>=0: ans+=1 else: break if A[-1]==x: ans+=1 print(ans)
p03254
s391344071
Accepted
N, x = map(int, input().split()) a = sorted(map(int, input().split())) ans = 0 for i in range(N): ans += 1 x -= a[i] if x < 0: ans -= 1 break if x > 0: ans -= 1 print(max(ans, 0))
p03254
s651498438
Accepted
N,x = map(int,input().split()) A = list(map(int,input().split())) A.sort() count = 0 flag = True for i in range(len(A)): if x - A[i] >= 0: x -= A[i] count += 1 else: flag = False break if x > 0 and flag: print(count-1) else: print(count)
p03254
s873896969
Accepted
n, x = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() if x < a[0]: print(0) else: cnt = 0 for i in range(n-1): if x - a[i] < 0: break cnt += 1 x -= a[i] print(cnt+1 if x == a[-1] else cnt)
p03254
s555577508
Accepted
from sys import stdin import math import re import queue input = stdin.readline MOD = 1000000007 INF = 122337203685477580 def solve(): N,x = map(int, input().split()) vec =list(map(int, input().split())) vec.sort() SUM = 0 i = 0 for p in range(N): SUM += vec[p] # print(SUM) if(SUM > x): break i += 1 if(x > sum(vec)): i -= 1 print(i) if __name__ == '__main__': solve()
p03254
s124310336
Accepted
N,X=map(int,input().split()) ai=list(map(int,input().split())) ai.sort() sum_of_the_candy=0 ans=0 if sum(ai)==X: ans=N elif sum(ai)<X: ans=N-1 else: for i in range(N): sum_of_the_candy=sum_of_the_candy+ai[i] if sum_of_the_candy <= X: ans = ans +1 else: break print(ans)
p03254
s770752026
Accepted
n,x = map(int, input().split()) a = list(map(int, input().split())) a.sort() count = 0 while True: if count > n-1: if x == a[n-1]: print(count) exit() else: print(count-1) exit() if a[count] < x: x-=a[count] count += 1 elif a[count] == x: print(count+1) exit() else: print(count) exit()
p03254
s519136704
Accepted
n, x = map(int, input().split()) a = sorted(map(int, input().split())) rest = x ans = 0 for i in range(n) : if rest > a[i] : if i != n-1 : rest -= a[i] ans += 1 else : print(ans) break elif rest == a[i] : ans += 1 print(ans) break else : print(ans) break else : print(ans)
p03254
s353760159
Accepted
N, x = map(int, input().split()) L = list(map(int, input().split())) l = sorted(L) c = 0 if sum(L) < x: print(len(l)-1) else: for i in range(N): if x < l[i]: break x = x - l[i] c += 1 print(c)
p03254
s079092703
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() total = 0 if x-sum(a) == 0: print(n) elif x >= sum(a) and x-sum(a) != 0: print(n-1) else: for i in range(n): total += a[i] if total > x: print(i) break
p03254
s893733353
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() y = x if y < a[0]: print(0) else: for i in range(n): x = x - a[i] if x > 0: continue elif x == 0: print(i+1) break elif x < 0: print(i) break if x > 0 and y > a[0]: print(n-1)
p03254
s189885486
Accepted
def main(): N, x = map(int, input().split()) A = [int(a) for a in input().split()] A.sort() ans = 0 for i in range(len(A)): if i == (len(A) - 1): if A[i] == x: ans += 1 else: if A[i] <= x: ans += 1 x -= A[i] print(ans) if __name__ == "__main__": main()
p03254
s600316964
Accepted
N, x = map(int, input().split()) children = sorted(list(map(int, input().split()))) count = 0 for child in children: if x >= child: x -= child count += 1 else: break else: if x != 0: count -= 1 print(count)
p03254
s775825745
Accepted
n, x = map(int, input().split()) l = sorted(list(map(int, input().split()))) kids = 0 ans = 0 for i in range(n): kids += l[i] if kids <= x: ans += 1 else: break if sum(l) >= x: print(ans) else: print(ans - 1)
p03254
s597283835
Accepted
N,x = map(int,input().split()) A = sorted(list(map(int,input().split()))) ans = 0 for i,a in enumerate(A): x = x-a if x<0: break ans+=1 print(ans-(x>0))
p03254
s234241452
Accepted
n, x = map(int, input().split()) a = sorted([int(i) for i in input().split()]) ans = 0 for i in range(n): x -= a[i] if x >= 0: ans += 1 if x > 0: print(ans -1) else: print(ans)
p03254
s162059276
Accepted
n,x=map(int,input().split()) l=sorted(list(map(int,input().split()))) c=0 for i in l: x-=i if x<0: c+=1 break else: c+=1 if x!=0: c-=1 print(c)
p03254
s675190778
Accepted
def main(): n, x = map(int, input().split()) A = list(map(int, input().split())) A_sorted = sorted(A) res = 0 for kids in A_sorted: x = x - kids if x >= 0: res += 1 if x > 0: print(res - 1) else: print(res) if __name__ == '__main__': main()
p03254
s418186362
Accepted
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)
p03254
s441352513
Accepted
n, x = map(int,input().split()) li = list(map(int,input().split())) if sum(li) < x: print(n-1) exit() li.sort() ans = 0 for i in li: x -= i if x >= 0: ans += 1 print(ans)
p03254
s875166485
Accepted
n, x = map(int, input().split()) a = list(map(int,input().split())) a_sort = sorted(a) ans = 0 for i in range(n-1): if x - a_sort[i] >= 0: x -= a_sort[i] ans += 1 if a_sort[n-1] == x: ans += 1 print(ans)
p03254
s642313739
Accepted
N, x = [int(x) for x in input().split()] a = [int(x) for x in input().split()] a.sort() ans = 0 for i in range(N): if x < a[i]: x = 0 break x -= a[i] ans += 1 if x > 0: ans -= 1 print(ans)
p03254
s808780109
Accepted
# A - Candy Distribution Again count = 0 N, x = map(int, input().split()) A = list(map(int, input().split())) A.sort() for i in range(N-1): x -= A[i] if(x < 0): break count += 1 if(x == A[N-1]): count += 1 print(count)
p03254
s510944873
Accepted
N, x = map(int, input().split()) a = sorted(map(int, input().split())) cnt = 0 for i in a: if x < i: break cnt += 1 x -= i else: if x > 0: cnt -= 1 print(cnt)
p03254
s136902474
Accepted
#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
p03254
s878094466
Accepted
def resolve(): ''' code here ''' N, x = [int(item) for item in input().split()] As = [int(item) for item in input().split()] As.sort() cnt = 0 while x > 0 and cnt < N: x -= As[cnt] if cnt == N-1: if x == 0: cnt += 1 else: if x >= 0: cnt += 1 print(cnt) if __name__ == "__main__": resolve()