problem_id
stringclasses
100 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
6
806
p03254
s598039100
Accepted
import sys import heapq, math from itertools import zip_longest, permutations, combinations, combinations_with_replacement from itertools import accumulate, dropwhile, takewhile, groupby from functools import lru_cache from copy import deepcopy N, x = map(int, input().split()) A = list(map(int, input().split())) A.sort() cnt = 0 for a in A: if x >= a: cnt += 1 x -= a else: x = 0 if x > 0: cnt -= 1 print(cnt)
p03254
s215792525
Accepted
N, x = map(int, input().split()) a = sorted(list(map(int, input().split()))) child = 0 candy = 0 for i in a: candy += i if candy <= x: child += 1 if sum(a) < x: child -= 1 print(int(child))
p03254
s315373758
Accepted
n,x = map(int, input().split()) a = list(map(int, input().split())) a.sort() cnt = 0 while a[cnt] <= x: x = x - a[cnt] cnt += 1 if cnt >= len(a): break if x > 0 and len(a) == cnt: cnt -= 1 print(cnt)
p03254
s836232220
Accepted
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)
p03254
s678078838
Accepted
n, x = map(int, input().split()) a = sorted(list(map(int, input().split()))) ans = 0 for i in a: x -= i if x < 0: break else: ans += 1 if ans == n and x != 0: print(ans-1) else: print(ans)
p03254
s871400660
Accepted
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: total = 0 for i in range(n): total += a[i] if total == x: print(i+1) break elif total > x: print(i) break
p03254
s154137225
Accepted
n,x = map(int,input().split()) a = sorted(list(map(int,input().split()))) cnt = 0 for i in range(n): x -= a[i] if x >= 0: cnt += 1 if x > 0: print(cnt-1) else: print(cnt)
p03254
s613885066
Accepted
n,x=map(int,input().split()) a=list(map(int,input().split())) a.sort() for i in range(n): if a[i]>x: print(i) exit() x-=a[i] if x==0: print(n) else: print(n-1)
p03254
s916173109
Accepted
N, x = map(int, input().split()) a = sorted(list(map(int, input().split()))) ans = 0 for i in range(N): if i == N-1: if x == a[i]: ans += 1 elif x >= a[i]: x -= a[i] ans += 1 else: break print(ans)
p03254
s194448440
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() s = 0 c = 0 for i in range(n): s += a[i] if s <= x: if i == n-1: if s == x: c += 1 else: c += 1 else: break print (c)
p03254
s006395900
Accepted
# AGC 027: A – Candy Distribution Again N, x = [int(s) for s in input().split()] a = [int(s) for s in input().split()] a.sort() distributed = 0 beGlads = 0 for i in range(N): if distributed + a[i] > x: break else: distributed += a[i] beGlads += 1 print(beGlads if sum(a) >= x else beGlads - 1)
p03254
s462874023
Accepted
N,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() ans = 0 for i in range(len(a)): if i == len(a)-1: if x == a[i]: ans += 1 break else: x -= a[i] if x < 0: break ans+=1 print(ans)
p03254
s803011821
Accepted
N,x=map(int,input().split()) a = list(map(int,input().split())) a.sort() ans=0 if sum(a)<x: print(N-1) else: for i in range(len(a)): if x>=a[i]: x -= a[i] ans += 1 else: break print(ans)
p03254
s492545584
Accepted
N, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() i = 0 n = 0 for gift in a: n += 1 x -= gift if n < len(a): if x < 0: break else: i += 1 elif n == len(a): if x == 0: i += 1 else: break print(i)
p03254
s133914365
Accepted
# -*- coding: utf-8 -*- n,x=map(int,input().split()) a=list(map(int,input().split())) ans=0 a.sort() for i in a: if i<=x: x-=i ans+=1 else: break else: if x>0: ans-=1 print(ans)
p03254
s927017406
Accepted
n, x=map(int, input().split()) a=list(map(int, input().split())) a.sort() b=0 for i in range(n): b+=a[i] if b>x: print(i) break if b<x: print(n-1) elif b==x: print(n)
p03254
s111360895
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = 0 frag = True for i in range(n): if x >= a[i]: x -= a[i] ans += 1 else: frag = False if frag and x > 0: print(ans-1) else: print(ans)
p03254
s333084839
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
s977071887
Accepted
def resolve(): N, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() okashi = 0 for i in range(N): okashi += a[i] if okashi > x: ans = i break elif okashi == x: ans = i+1 break else: ans = N-1 print(ans) resolve()
p03254
s359388648
Accepted
n,x = map(int,input().split()) a = list(map(int,input().split())) cnt = 0 a.sort() if sum(a) < x: print(n-1) elif sum(a) == x: print(n) else: for i in a: if x >= i: cnt += 1 x -= i print(cnt)
p03254
s864970077
Accepted
import math N, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = 0 for i in range(N): if i < N - 1 and x >= a[i] or i == N - 1 and x == a[i]: ans += 1 x -= a[i] print(ans)
p03254
s651313967
Accepted
n,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() ans = 0 for i in a: if x >= 0: x -= i ans += 1 else: break if x > 0: ans -= 1 if x < 0: ans -= 1 print(ans)
p03254
s745394701
Accepted
N, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() happy_kid = 0 for i in range(N): x = x - a[i] if i == N - 1: if 0 == x: happy_kid += 1 elif x >= 0: happy_kid += 1 else: break print(happy_kid)
p03254
s525643999
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]: if i == n-1: if a[i] == x:ans+=1 else: x -= a[i] ans +=1 else:break print(ans)
p03254
s435910994
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() happy = 0 for i in range(n-1): if a[i] <= x: x -= a[i] happy += 1 else: break happy += 1 if x == a[n - 1] else 0 print(happy)
p03254
s587528669
Accepted
N,x = map(int,input().split()) A = list(map(int,input().split())) if sum(A) < x: print(N-1) else: A.sort() count = 0 while(x > 0): x -= A[count] if x >= 0: count += 1 print(count)
p03254
s143994830
Accepted
import itertools N, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() a = list(itertools.accumulate(a)) cnt = 0 for i in range(len(a)): if x > a[i]: if i == len(a)-1: break cnt += 1 elif x == a[i]: cnt += 1 break else: break print(cnt)
p03254
s882839498
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
s073456126
Accepted
n,x = map(int,input().split()) a_lst = sorted(list(map(int,input().split()))) cnt = 0 if x == sum(a_lst): print(len(a_lst)) elif x > sum(a_lst): print(len(a_lst)-1) else: for i in a_lst: x -= i if x < 0: break cnt += 1 print(cnt)
p03254
s944008900
Accepted
n,x=map(int,input().split()) a=list(map(int,input().split())) count=0 a.sort() for i in range(n): x-=a[i] if x>0: count+=1 elif x==0: count+=1 print(count) exit() else: print(count) exit() print(count-1)
p03254
s342607268
Accepted
N, x = map(int, input().split()) a_list = list(map(int, input().split())) #%% ans = 0 a_list.sort() for a in a_list: x = x - a if x < 0: break ans += 1 if x > 0 and ans == N: ans -= 1 print(ans)
p03254
s391241176
Accepted
import numpy as np n,x = map(int,input().split()) li = list(map(int,input().split())) li.sort() res = np.cumsum(li) cnt=0 if res[-1] == x: cnt = len(res) elif res[-1] > x: for i in res: if i <= x: cnt += 1 else: break else: cnt = len(res) -1 print(cnt)
p03254
s203992085
Accepted
n, x = [int(i) for i in input().split()] A = sorted([int(i) for i in input().split()]) ans = 0 for i in range(n): if A[i] <= x: if i == n - 1: if x == A[i]: ans += 1 else: x -= A[i] ans += 1 else: break print(ans)
p03254
s582874032
Accepted
from itertools import accumulate from bisect import bisect_right def main(): children, cookies = map(int, input().split()) target = sorted(list(map(int, input().split()))) sum_target = sum(target) if sum_target < cookies: print(children - 1) elif cookies < target[0]: print(0) else: accumulate_target = list(accumulate(target)) print(bisect_right(accumulate_target, cookies)) if __name__ == '__main__': main()
p03254
s159863584
Accepted
N, x = map(int, input().split()) A = list(map(int, input().split())) A.sort() res = 0 for i, a in enumerate(A): x -= a if x >= 0: res += 1 else: break else: if x > 0: res -= 1 print(res)
p03254
s951174819
Accepted
N, x = map(int, input().split()) sweets = list(map(int, input().split())) if x == sum(sweets): print(N) else: # 少ないものから順に取っていく sweets.remove(max(sweets)) ans = N - 1 while True: if x >= sum(sweets): print(ans) break sweets.remove(max(sweets)) ans -= 1
p03254
s277768844
Accepted
from itertools import accumulate from operator import add N, x = map(int, input().split()) A = list(map(int, input().split())) A.sort() if sum(A) == x: print(N) else: t = len(list(filter(lambda y: y <= x, accumulate(A, func=add)))) if t == N: print(N - 1) else: print(t)
p03254
s619836163
Accepted
N,x = map(int, input().split()) A = [int(i) for i in input().split()] A.sort() c = 0 for i in range(N): x -= A[i] if x >= 0: c += 1 if x <= 0: print(c) break else: print(N - 1)
p03254
s113091362
Accepted
N, x = map(int, input().split()) A = list(map(int, input().split())) A.sort() sum = 0 ans = 0 for i,a in enumerate(A): sum += a if sum == x: ans = i + 1 break elif sum > x: break elif i + 1 == N and sum < x: ans = i break ans = i + 1 print(ans)
p03254
s616022412
Accepted
N,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() if sum(a) == x: print(N) exit() if sum(a) <= x: print(N-1) exit() ans = 0 for i in range(N): ans += a[i] if ans == x: print(i+1) exit() if ans > x: print(i) exit()
p03254
s544849308
Accepted
N, x = map(int, input().split()) A = [int(x) for x in input().split()] A = sorted(A) cnt=0 for i in range(N): x -= A[i] if x < 0: break cnt += 1 if cnt==N and x > 0: cnt -= 1 print(cnt)
p03254
s311769384
Accepted
N, x = map(int, input().split()) a = [int(a) for a in input().split()] if sum(a) == x: print(N) exit() sort_a = sorted(a) count = 0 for i in range(1,N+1): if sum(sort_a[:i]) <= x: if i < N: count += 1 else: pass else: break print(count)
p03254
s899259310
Accepted
N, x = map(int, input().split()) A = sorted(list(map(int, input().split()))) S = [0] for i in range(N): S.append(S[i] + A[i]) # print(S) l = -1 r = N+1 while r - l > 1: m = l + (r-l)//2 if S[m] > x: r = m else: l = m print(l - (l == N and S[l] < x))
p03254
s159775373
Accepted
N, X = map(int, input().split()) A = list(map(int, input().split())) A.sort() S = 0 ans = 0 for i in range(N): S += A[i] if S <= X: ans += 1 else: break if S < X: ans = N-1 print(ans)
p03254
s428674325
Accepted
#CandyDistributionAgain n, x = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) 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] >= 0: x -= a[i] ans += 1 else: break print(ans)
p03254
s206161002
Accepted
n, x = map(int, input().split()) aaa = list(map(int, input().split())) aaa.sort() ans = 0 for a in aaa: if x < a: break ans += 1 x -= a else: if x > 0: ans -= 1 print(ans)
p03254
s618343175
Accepted
import sys N, x = map(int, input().split()) a = sorted(map(int, input().split())) ans = 0 score_x = x if score_x < a[0]: print(0) sys.exit() for i in range(N): if i == (N-1): if a[i] == score_x: ans = ans + 1 score_x = (score_x - a[i]) else: break if score_x >= a[i]: score_x = (score_x - a[i]) ans = ans + 1 print(ans)
p03254
s641103692
Accepted
import sys import copy a = [int(c) for c in input().split()] N=a[0] x=a[1] a = [int(c) for c in input().split()] a.sort() for i in range(N): x-=a[i] if x<0: print(i) sys.exit(0) elif x==0: print(i+1) sys.exit(0) print(N-1)
p03254
s674870695
Accepted
n, x = map(int,input().split()) children = list(map(int,input().split())) children.sort() count=0 c = 0 if x < children[0]: print(0) exit() for i in range(n): count += children[i] c += 1 if count == x: print(c) exit() elif count > x: print(c-1) exit() print(n-1)
p03254
s291091845
Accepted
N,x = map(int,input().split()) a = list(map(int,input().split())) a = sorted(a) count = 0 while(x >= 0): if(count == N): break tmp = a.pop(0) if(x >= tmp): x = x - tmp count += 1 else: break if(count == N and x != 0): count -= 1 print(str(count))
p03254
s624039661
Accepted
N, x = [int(i) for i in input().split(" ")] lst = [int(i) for i in input().split(" ")] lst.sort() cnt = 0 for i in range(0,N-1): if x >= lst[i]: x -= lst[i] cnt += 1 else: break print(cnt+(x==lst[N-1]))
p03254
s531396912
Accepted
import sys N, x = map(int, input().split()) a = list(map(int, input().split())) if sum(a) == x: print(N) sys.exit() else: a.sort() ans = 0 for i in range(N-1): if a[i] <= x: ans += 1 x -= a[i] else: print(ans) break else: print(ans)
p03254
s577238701
Accepted
n,x=map(int,input().split()) a=list(map(int,input().split())) a.sort() ans=-1 num=0 for i in range(n): num+=a[i] if num>x: ans=i break if ans==-1: if num==x: print(n) else: print(n-1) else: print(ans)
p03254
s747255954
Accepted
def solve(): N, x = map(int, input().split()) A = list(map(int, input().split())) A.sort() ans = 0 for i in range(N): if i==N-1: if A[i]==x: ans += 1 continue if x>=A[i]: ans += 1 x -= A[i] return ans print(solve())
p03254
s557861770
Accepted
N, x = map(int, input().split()) child_list = list(map(int, input().split())) count = 0 for i, child in enumerate(sorted(child_list)): x -= child if x < 0: break if (i == len(child_list) - 1) and x != 0: break count += 1 print(count)
p03254
s238548412
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) if sum(a) < x: print(n - 1) elif sum(a) == x : print(n) else: a.sort() cnt = 0 for i in range(n): x -= a[i] if x < 0: print(cnt) quit() cnt += 1
p03254
s741396547
Accepted
N, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = 0 for i, v in enumerate(a): x -= v if x < 0: ans = i break if x == 0: ans = i + 1 break if i == N - 1: ans = i + 1 if x > 0: ans -= 1 print(ans)
p03254
s541659083
Accepted
# vim: fileencoding=utf-8 def main(): n, x = map(int, input().split()) li = list(map(int, input().split())) li.sort() ans = 0 for i in range(len(li)): x = x - li[i] if x < 0: break ans += 1 if x > 0: ans -= 1 print(ans) if __name__ == "__main__": main()
p03254
s397400900
Accepted
import itertools n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() a = list(itertools.accumulate(a)) cnt = 0 for i in range(n): if i==n-1 and a[-1]!=x: pass elif a[i]<=x: cnt+=1 print(cnt)
p03254
s713711649
Accepted
N, x = map(int,input().split()) al = list(map(int,input().split())) al.sort() cnt = 0 for a in al[:N-1]: if x >= a: x -= a cnt += 1 else: break if al[-1] == x: cnt += 1 print(cnt)
p03254
s758016348
Accepted
N, x = map(int, input().split()) a = list(map(int, input().split())) a_min = sorted(a) temp = 0 count = 0 for i in range(N): temp += a_min[i] if temp > x: break count += 1 print(count - 1 if temp < x else count)
p03254
s094030786
Accepted
n, x = map(int, input().split()) A = list(map(int, input().split())) A.sort() ans = 0 for i, a in enumerate(A): if i != n-1: if x >= a: ans += 1 x -= a else: break else: if x == a: ans += 1 else: break print(ans)
p03254
s350292687
Accepted
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]: x-=a[i] ans+=1 else: print(ans) exit() if x==0: print(ans) else: print(ans-1)
p03254
s391145352
Accepted
N,x=map(int,input().split()) a=list(map(int,input().split())) man=[0]*N a.sort() ans=0 for i in range(N): if a[i]<=x: x-=a[i] a[i]=0 ans+=1 else: break if ans==N: if x!=0: ans-=1 if ans<0: ans=0 print(ans)
p03254
s334886741
Accepted
N, x = map(int, input().split()) L = list(map(int,input().split())) L_sorted = sorted(L, reverse=False) remain = x ans = 0 for j in range(N): if remain>= L_sorted[j] and j != N-1: remain = remain - L_sorted[j] ans += 1 if j == N-1 and L_sorted[j] == remain: ans += 1 print(ans)
p03254
s075900919
Accepted
n,x = map(int,input().split(' ')) A = list(map(int,input().split(' '))) A.sort() i = 0 while i < n: if x > A[i]: x = x - A[i] i += 1 elif x == A[i]: x = 0 i += 1 break else: break if i == n and x > 0: print(i-1) else: print(i)
p03254
s824934291
Accepted
N,x=map(int,input().split()) a=[int(x) for x in input().split()] a.sort() count=0 if sum(a)==x: count=N elif sum(a)<x: count=N-1 else: for i in range(N): if sum(a[:i])<=x and sum(a[:i+1])>x: count=i print(count)
p03254
s772039889
Accepted
N,x=input().split() X=int(x) n=int(N) y=0 A = [int(i) for i in input().split()] A.sort() for z in range(n): y+=A[z] if y>=X: if y==X: print(z+1) else: print(z) break else: print(n-1)
p03254
s592550558
Accepted
n, x = map(int, input().split()) ls = list(map(int, input().split())) ans = 0 m = x ls.sort() for i in range(n): x = x - ls[i] if x >= 0: ans += 1 else: break if m > sum(ls): print(ans - 1) else: print(ans)
p03254
s778279924
Accepted
N, x = map(int, input().split()) a = sorted(list(map(int, input().split()))) ans = 0 snack_sum = 0 while ans < N: snack_sum += a[ans] if snack_sum > x: break else: ans += 1 if ans == N: if snack_sum != x: print(ans - 1) exit() print(ans)
p03254
s331649831
Accepted
N, x = map(int,input().split()) a = list(map(int,input().split())) a.sort() count = 0 for i in range(N): x = x - a[i] if x < 0: break count += 1 if x > 0: count -= 1 print(count)
p03254
s445043914
Accepted
import numpy as np N, x = map(int, input().split()) a = list(map(int, input().split())) a = np.sort(np.array(a)) cumul = np.cumsum(a) sign = np.sign(cumul - x) if np.all(sign == -1): print(N - 1) else: print(np.sum(sign <= 0))
p03254
s617656091
Accepted
n, x = map(int, input().split()) a = [int(an) for an in input().split()] a.sort() ans = 0 num_candy = 0 for an in a: num_candy += an if num_candy <= x: ans += 1 if num_candy < x: ans -= 1 print(ans)
p03254
s400609055
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = [0]*n if (sum(a) == x): print(n) else: for i in range(n): if (x >= a[i]): ans[i] = 1 x -= a[i] else: print(sum(ans)) exit() if (0 in ans): print(sum(ans)) else: print(sum(ans)-1)
p03254
s490316833
Accepted
N, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans, cur = 0, 0 if(sum(a) <= x): if(sum(a) != x): N -= 1 print(N) exit(0) for i in range(N): cur += a[i] if(cur > x): break ans += 1 print(ans)
p03254
s873451070
Accepted
N,X = list(map(int,input().split())) A = list(map(int,input().split())) A.sort() count = 0 for i in A: if X >= i: X = X - i count += 1 else: break if X > 0 and count == N: count -= 1 print(max(count,0))
p03254
s604733852
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 a.sort() for num in a: if x >= num: ans += 1 x -= num else: break else: if x == 0: print(ans) else: print(ans - 1) exit() print(ans)
p03254
s499737277
Accepted
N,x = map(int, input().split()) A = sorted(map(int, input().split())) S = 0 c = 0 for i in range(N): S += A[i] if S < x: print(N-1) else: for i in range(N): b = x - A[i] if b > 0: c += 1 x -= A[i] elif b == 0: c += 1 break else: break print(c)
p03254
s620055493
Accepted
N, x = map(int, input().split()) A = sorted(list(map(int, input().split()))) res = 0 for a in A: x -= a res += 1 if x < 0: x = abs(x) break elif x == 0: break print(max(res-1, 0) if x>0 else res)
p03254
s746749010
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: break ans += 1 if x>0: ans -= 1 print(ans)
p03254
s039785938
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() for i in range(n): x-=a[i] if x<0: print(i) break if x >0: print(n-1) elif x==0: print(n)
p03254
s295878592
Accepted
N, x = map(int, input().split()) a = list(map(int, input().split())) cont = 0 for i in sorted(a): x -= i if x >= 0: cont += 1 else: break if x > 0: cont -= 1 print(cont)
p03254
s609285809
Accepted
N, x = map(int, input().split()) A = list(map(int, input().split())) A.sort() for i in range(1, len(A)+1): #print(i) #print(A[:i]) #print(sum(A[:i])) if x < sum(A[:i]): #print('a') print(i-1) break elif x == sum(A[:i]): #print('b') print(i) break else: if i == len(A): print(i-1)
p03254
s724917346
Accepted
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N, X = map(int, input().split()) A = list(map(int, input().split())) A.sort() if sum(A) == X: print(N) else: ans = 0 for a in A[:-1]: if a <= X: ans += 1 X -= a else: break print(ans) if __name__ == '__main__': main()
p03254
s149442837
Accepted
N, x = list(map(int, input().split())) a_list = list(map(int, input().split())) ans = 0 total = 0 a_list.sort() for i, a in enumerate(a_list): total += a if x < total: break elif i == len(a_list) - 1 and x > total: None else: ans += 1 print(ans)
p03254
s111398382
Accepted
N,x=map(int, input().split()) A=list(map(int, input().split())) ans=0 A=sorted(A) for i in range(N): a=A[i] if x>=a: x-=a ans+=1 else: i-=1 break if x>0 and i==N-1: ans-=1 print(ans)
p03254
s751684063
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 x < 0: break else: ans += 1 if x > 0: ans -= 1 else: pass print(ans)
p03254
s220944698
Accepted
n,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() i = 0 while True: x = x - a[i] if x >= 0 and i+1 != len(a): i += 1 elif x == 0 and i+1 == len(a): i += 1 break else: break print(i)
p03254
s957281392
Accepted
from itertools import accumulate from bisect import bisect_right N, x, *A = map(int, open(0).read().split()) A.sort() S = list(accumulate(A)) if S[-1] == x: print(N) else: k = bisect_right(S, x) print(N - 1 if k == N else k)
p03254
s391766586
Accepted
n,x=list(map(int,input().split())) a=sorted(list(map(int,input().split()))) i=0 num=0 for i in a: x=x-i num+=1 if x==0: break if x<=0: num-=1 break if x>0: num-=1 print(num)
p03254
s084437858
Accepted
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 N,x=map(int,input().split()) a=list(map(int,input().split())) a.sort() ans=0 for y in a: if y<=x: ans+=1 x-=y if ans==N and x>0: ans-=1 print(ans)
p03254
s039063749
Accepted
n,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() for i in range(1,n): if sum(a[:i]) > x: print(i-1) exit() if sum(a[:n]) == x: print(n) else: print(n-1)
p03254
s616411368
Accepted
n, x = list(map(int, input().split(' '))) ss = list(map(int, input().split(' '))) r = x count = 0 for s in sorted(ss): if r - s < 0: break else: n -= 1 r -= s count += 1 if r > 0 and n <= 0: count -= 1 print(count)
p03254
s477151014
Accepted
N, x = map(int, input().split()) a = sorted(map(int, input().split())) result = 0 a_sum = 0 for i in range(N): if i == N - 1: result += a[i] == x elif x >= a[i]: x -= a[i] result += 1 else: break print(result)
p03254
s431583807
Accepted
N, x = [int(x) for x in input().split()] a = sorted([int(x) for x in input().split()]) ans = 0 if sum(a) < x: ans = N - 1 elif sum(a) == x: ans = N else: for i in range(N): if x >= a[i]: x -= a[i] ans += 1 print(ans)
p03254
s315025643
Accepted
n , x = map(int, input().split()) a = list(map(int,input().split())) a.sort() ans = 0 while x>0 and a: c = a.pop(0) if x>=c: ans +=1 x-=c if x>0: ans-=1 print(ans)
p03254
s132392132
Accepted
def main(): n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = 0 for v in a: if v > x: x = 0 break else: x -= v ans += 1 if 0 < x: ans -= 1 print(ans) if __name__ == "__main__": main()
p03254
s505727712
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = 0 bit = 0 for i in range(n): if a[i] <= x: x -= a[i] ans += 1 else: bit = 1 if x != 0 and bit == 0: ans = max(0, ans - 1) print(ans)
p03254
s474107905
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: p = 0 a.sort() for i in range(n): if a[i] > x: break else: x -= a[i] p += 1 print(p)
p03254
s020249440
Accepted
N,x = map(int,input().split()) a = list(map(int,input().split())) a.sort() cnt=0 for i in range(N): if x - a[i] >= 0: cnt+=1 x = x-a[i] if x >0: if cnt == 0: cnt = 0 else: if cnt == len(a): cnt = cnt -1 print(cnt)