problem_id stringclasses 100
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 6 806 |
|---|---|---|---|
p03254 | s604268035 | 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)
exit()
if cou == x:
print(n)
else:
print(n-1) |
p03254 | s069999870 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
total = sum(a)
ans = 0
if x == total:
ans = n
elif x > total:
ans = n - 1
else:
for v in a:
x -= v
if x < 0:
break
ans += 1
print(ans) |
p03254 | s720460985 | Accepted | N,x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
A = sum(a)
if x > A:
print(N-1)
else:
cnt = 0
for i in range(N):
if x >= a[i]:
x -=a[i]
cnt += 1
print(cnt) |
p03254 | s764241819 | Accepted | N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
if x>sum(A):
print(N-1)
exit()
if x==sum(A):
print(N)
exit()
ans = 0
for i in range(N):
if sum(A[:i]) <= x:
ans = i
print(ans) |
p03254 | s926870694 | Accepted | 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 x < a[i]:
print(i)
break
x -= a[i]
|
p03254 | s444541601 | Accepted | n, x = map(int, input().split())
ls = list(map(int, input().split()))
s = sum(ls)
if s < x:
print(n - 1)
elif s == x:
print(n)
else:
ls.sort()
a = 0
for i in range(n):
if ls[i] <= x:
x -= ls[i]
a += 1
else:
print(a)
break
|
p03254 | s264151022 | Accepted | N, x = map(int,input().split())
a = sorted([int(i) for i in input().split()])
count = 0
if sum(a) == x:
print(len(a))
else:
for i in a:
x = x-i
if x<0:
break
count+=1
if count == N:
print(N-1)
else:
print(count) |
p03254 | s420846691 | Accepted | def LI():
return list(map(int, input().split()))
N, total = LI()
a = LI()
Nlist = [0]*N
a.sort()
ans = 0
if sum(a) == total:
ans = N
elif sum(a) < total:
ans = N-1
else:
for i in range(N):
if total == a[i]:
ans += 1
break
elif total > a[i]:
ans += 1
total -= a[i]
else:
break
print(ans)
|
p03254 | s747736658 | Accepted | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n,x = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
s = 0
for i in range(n):
if s+a[i]==x or (i<n-1 and s+a[i]<=x):
s += a[i]
# print(s)
else:
i -= 1
break
print(i+1) |
p03254 | s481492340 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
l = sorted(a)
flag = False
for i in range(n):
x -= l[i]
if x < 0:
flag = True
break
if flag:
print(i)
elif x == 0:
print(n)
elif x > 0:
print(n - 1)
|
p03254 | s265868786 | Accepted | n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
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 | s848932598 | Accepted | import sys
input = sys.stdin.readline
def main():
N, x = map(int, input().split())
a_list = list(map(int, input().split()))
ans = 0
for a in sorted(a_list):
if a <= x:
ans += 1
x -= a
else:
break
if x == 0 or ans != N:
print(ans)
else:
print(max(ans - 1, 0))
if __name__ == '__main__':
main() |
p03254 | s995004126 | Accepted | N,X=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
count=0
for i in range(N):
if i==(N-1):
if X!=L[i]:
count=count
else:
count+=1
elif L[i]<=X:
X-=L[i]
count+=1
print(count) |
p03254 | s988314381 | Accepted | #template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueγγε§γγ
N,x = inputlist()
a = inputlist()
a.sort()
count=0
for i in range(N):
x -=a[i]
if x < 0:
print(count)
exit()
count +=1
if x >0:
count -=1
print(count) |
p03254 | s026451080 | Accepted | from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
n,x=nii()
a=lnii()
a.sort()
a_sum=0
for i in range(n):
a_sum+=a[i]
if a_sum>x:
print(i)
exit()
if x>sum(a):
print(n-1)
else:
print(n) |
p03254 | s910071423 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if sum(a) == x:
print(N)
else:
i = 0
candy = 0
while candy <= x and i <= N - 1:
candy += a[i]
i += 1
print(i - 1) |
p03254 | s309689865 | Accepted | N,X=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=0
for i in range(0,N):
if X>=a[i]:
X=X-a[i]
b+=1
if i==len(a)-1 and (X+a[i])!=a[i]:
b-=1
break
else:
break
print(b) |
p03254 | s417131778 | Accepted | N,X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
k1 = k2 = 0
for i in range (N):
if sum(A[:i+1]) > X:
k1 = i
k2 = 1
break
elif sum(A) == X:
k1 = N
k2 = 1
break
if k2 == 0:
k1 = N - 1
print(k1) |
p03254 | s298431781 | Accepted | import sys
n,x = map(int, sys.stdin.readline().rstrip("\n").split())
a = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
a.sort()
ans = 0
for i in range(n):
if i == n-1:
if x - a[i] == 0:
ans += 1
else:
if x-a[i] >= 0:
x = x-a[i]
ans += 1
print(ans) |
p03254 | s661318974 | Accepted | n,x=[int(i) for i in input().split()]
a_list=[int(i) for i in input().split()]
a_list.sort()
if x>sum(a_list):
print(n-1)
#ε
¨ε‘εγΆ
elif x==sum(a_list):
print(n)
else:
sum=0
count=0
for i in range(n):
sum+=a_list[i]
if sum<=x:
count+=1
else:
break
print(count)
|
p03254 | s374140490 | Accepted | from itertools import accumulate
N, X = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
p = list(accumulate(a))
result = 0
for i, x in enumerate(p):
if X < x:
break
if i == N-1 and x != X:
break
result += 1
print(result) |
p03254 | s237459482 | 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)
exit()
elif x==0:
print(-~i)
exit()
print(n-1) |
p03254 | s693312145 | Accepted | def main():
N, x = map(int, input().split())
a = sorted(map(int, input().split()))
cnt = 0
for i in range(N):
if a[i] <= x:
cnt += 1
x -= a[i]
else:
break
if cnt == N and x > 0:
cnt -= 1
print(cnt)
if __name__ == "__main__":
main() |
p03254 | s462539000 | Accepted | n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
sweets=0
ans = 0
for i in range(n):
sweets += a[i]
if sweets <= x:
ans += 1
else:
break
if sweets < x:
print(ans-1)
else:
print(ans) |
p03254 | s616460539 | Accepted | 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
if x == 0 or cnt < n:
print(cnt)
else:
print(cnt-1) |
p03254 | s087801606 | 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:
ans = 0
a.sort()
for i in range(n):
if a[i] > x:
break
else:
x -= a[i]
ans += 1
print(ans) |
p03254 | s734212463 | 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 | s239234496 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in a:
if x < i:
break
x -= i
count += 1
else:
if x:
count -= 1
print(count) |
p03254 | s900033476 | Accepted | N, x = map(int, input().split())
an = list(map(int, input().split()))
an.sort()
ans = 0
for a in an:
x -= a
if x < 0:
break
ans += 1
if x > 0:
ans -= 1
print(ans)
|
p03254 | s116423640 | Accepted | N,x=map(int,input().split())
a=list(map(int,input().split()))
temp=x
ans=0
a.sort()
i=-1
while True:
i+=1
x-=a[i]
if x<0:
break
ans+=1
if ans==N:
break
if sum(a)<temp:
ans-=1
print(ans)
|
p03254 | s430035961 | Accepted | N,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
total=sum(a)
#γγγγδ½γε ΄ε
if total<x:
print(N-1)
#ι
γγγγε ΄ε
elif total==x:
print(N)
#εδΎγδ½γε ΄ε
else:
ans=0
d=[0]*N
for i in range(N):
if x>=a[i]:
x-=a[i]
d[i]=1
ans=d.count(1)
print(ans)
|
p03254 | s689074902 | 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(res) |
p03254 | s147268520 | Accepted | n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in range(n-1):
if a[i] <= x:
x = x - a[i]
count += 1
if a[n-1] == x:
count += 1
print(count) |
p03254 | s157169323 | Accepted | N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
i = 0
while i<N and x>=A[i]:
x -= A[i]
i += 1
if x>0 and i==N:
i -= 1
print(i) |
p03254 | s648524963 | Accepted | N, x = map(int, input().split())
A = sorted(map(int, input().split()))
if sum(A) == x:
print(N)
else:
c = 0
for ai in A:
x -= ai
if x <= 0:
break
c += 1
if c == N:
print(N - 1)
else:
print(c + 1 if x == 0 else c) |
p03254 | s713715104 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
sort_a = sorted(a)
count = 0
for y in range(len(sort_a)):
if y != len(sort_a) - 1:
if sort_a[y] <= x:
x -= sort_a[y]
count += 1
else:
break
else:
if sort_a[y] == x:
count += 1
print(count)
|
p03254 | s241954318 | Accepted | N, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
children = [0] * N
a.sort()
kashi = 0
n = N
if a[0] > x:
print(0)
elif sum(a) == x:
print(N)
else:
for i in range(0,n):
if kashi > x:
break
kashi += a[i]
children[i] += 1
# print(kashi)
if kashi == x :
print(N - children.count(0))
else:
print(N - children.count(0) - 1) |
p03254 | s865609383 | Accepted | import sys
input = sys.stdin.readline
# A - Candy Distribution Again
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
candies = 0
ans = 0
for ai in a:
if candies < x:
candies += ai
ans += 1
else:
break
if candies != x:
ans -= 1
print(ans)
|
p03254 | s729251477 | Accepted | n, y = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
if y == sum(a):
ans = n
elif y > sum(a):
ans = n -1
else:
for i in range(n):
if y - a[i] >= 0:
y -= a[i]
ans += 1
else:
break
print(ans) |
p03254 | s306874977 | Accepted | # coding: utf-8
def main():
_, 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
else:
ans += 1
if x > 0 and ans > 0:
ans -= 1
print(ans)
if __name__ == "__main__":
main()
|
p03254 | s579441251 | Accepted | _, x, *a = map(int, open(0).read().split())
c = 0
for i in sorted(a):
x -= i
if x<0:
break
c += 1
print(c - (x>0))
|
p03254 | s526496674 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=False)
count = 0
for i in range(N):
if x>=a[i]:
count += 1
x -= a[i]
else:
break
if (x!=0)and(count==N):
count -= 1
print(count) |
p03254 | s278944210 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
n = 0
if x > sum(a):
print(N-1)
exit()
for i in a:
if x >= i:
x -= i
n += 1
else:
break
print(n) |
p03254 | s504205559 | Accepted | N, x = map(int, input().split())
a_list = sorted(list(map(int, input().split())))
for i in range(N):
x = x - a_list[i]
if x < 0:
break
if i == N-1 and x == 0:
i += 1
print(i)
|
p03254 | s329954675 | Accepted | n,x = map(int,input().split())
a = sorted(map(int,input().split()))
ans = 0
for i in a[:-1]:
if i <= x:
ans += 1
x -= i
else:
break
if x == a[-1]:
ans += 1
print(ans) |
p03254 | s040603721 | Accepted | 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 | s298623985 | Accepted | #S= str(input())
#T= str(input())
N,X = map(int,input().split())
#N = int(input())
A = list(map(int,input().split()))
c=0
while X>=min(A):
if len(A)==1:
if X==A[0]:
c+=1
print(c)
exit()
else:
print(c)
exit()
if X>=min(A):
X-=min(A)
A.remove(min(A))
c+=1
print(c)
|
p03254 | s342032042 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = 0
num = 0
if x>sum(a):
print(len(a)-1)
else:
for i in range(len(a)):
if x >= a[i]:
x -= a[i]
num += 1
else:
break
print(num)
|
p03254 | s765346849 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n-1):
if x >= a[i]:
x -= a[i]
ans += 1
if x == a[-1]:
ans += 1
print(ans) |
p03254 | s715577178 | Accepted | def resolve():
N, x = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])
sumA = 0
cnt = 0
for i in range(N):
if A[i] <= (x - sumA):
sumA += A[i]
cnt += 1
else:
break
else:
if sumA != x:
cnt -= 1
print(cnt)
resolve()
|
p03254 | s583258658 | Accepted | n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr.sort()
ans = 0
for i in range(n-1):
x -= arr[i]
if x >= 0:
ans += 1
if arr[-1] == x:
ans += 1
print(ans) |
p03254 | s333583700 | Accepted | #Candy Distribution Again
n,x = map(int, input().split())
s= list(map(int,input().split()))
s.sort()
s.reverse
ans=0
if s[0]>x:
print(ans)
else :
for i in s:
x=x-i
if x>=0:
ans+=1
else :
break
if x>0:
ans-=1
print(ans)
|
p03254 | s306963031 | 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 and x > A[i]:
break
if x >= A[i]:
x -= A[i]
cnt+=1
else:
break
print(cnt)
|
p03254 | s878061366 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.reverse()
if x > sum(a):
print(n - 1)
else:
c = 0
while x >= a[-1]:
x -= a.pop()
c += 1
if c == n:
break
print(c)
|
p03254 | s797475168 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
if sum(a) < x:
print(n-1)
exit()
for i in range(n):
if x>=a[i]:
cnt+=1
x-=a[i]
else:
break
print(cnt) |
p03254 | s706813622 | Accepted | n,x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
cnt=0
for i,X in enumerate(a):
if x>=X:
cnt+=1
x-=X
else:
break
if cnt==n and x>0:
cnt-=1
print(cnt) |
p03254 | s700531364 | Accepted | N, x = input().split(' ')
N = int(N)
x = int(x)
a = input().split(' ')
a = [int(a[i]) for i in range(N)]
a = sorted(a)
count = 0
for i in range(N):
if x - a[i] < 0:
x -= a[i]
break
else:
x -= a[i]
count += 1
if x > 0:
count -= 1
print(count) |
p03254 | s520220864 | Accepted | 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:
cnt -= 1
print(cnt)
|
p03254 | s165507117 | Accepted | n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
if x>=a[i]:
ans+=1
x-=a[i]
else:
break
if ans == n:
if x!=0:
ans-=1
print(ans) |
p03254 | s977479737 | Accepted | def last_alert(list_):
iter_ = iter(list_)
n = next(iter_)
for i in iter_:
yield n, False
n = i
yield n, True
N, X = map(int, input().split())
ans = 0
for i, is_last in last_alert(sorted(map(int, input().split()))):
if is_last and X != i:
break
elif X < i:
break
X -= i
ans += 1
print(ans)
|
p03254 | s614128135 | Accepted | # AGC 027 A - Candy Distribution Again
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
else:
break
elif x >= a[i]:
x -= a[i]
count += 1
else:
break
print(count) |
p03254 | s875704605 | Accepted | def resolve():
import sys
n,x=map(int, input().split())
l=list(map(int, input().split()))
l.sort()
cnt=0
for i in range(n):
if l[i]<=x:
x-=l[i]
cnt+=1
else:
break
if cnt==n and x>0:
cnt-=1
print(cnt)
resolve()
|
p03254 | s808505977 | Accepted | n, x = [int(w) for w in input().split()]
a_li = [int(w) for w in input().split()]
a_li.sort()
ans = 0
for a in a_li:
x -= a
if x >= 0:
ans += 1
else:
break
if x == 0:
pass
else:
if x > 0:
ans = max(ans - 1, 0)
print(ans)
|
p03254 | s654996942 | Accepted | N, x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
ans = 0
for i in range(len(a) - 1):
x -= a[i]
if x >= 0:
ans += 1
else:
break
x -= a[N - 1]
if x == 0:
ans += 1
print(ans) |
p03254 | s571333264 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for val in a[:-1]:
x -= val
if x < 0:
break
cnt += 1
if x == a[-1]:
cnt += 1
print(cnt) |
p03254 | s409784559 | Accepted | n,k = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
sum1 = 0
cnt = 0
if k < L[0]:
print(0)
exit()
for i in range(n):
sum1 +=L[i]
if sum1 <=k:
cnt +=1
if i == n-1 and sum1 != k:
cnt -=1
else:
break
print(cnt) |
p03254 | s941489449 | Accepted | N,x=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
cnt=0
for i in range(N):
if sum(a)==x:
cnt=N
elif sum(a)>x:
if x>=a[i]:
x-=a[i]
cnt+=1
else:
break
else:
cnt=N-1
print(cnt) |
p03254 | s169921747 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for i in range(n):
if i == n - 1:
if x == a[i]:
cnt += 1
elif x >= a[i]:
x -= a[i]
cnt += 1
print(cnt)
|
p03254 | s468380639 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
c = 0
a_sorted = sorted(a)
for i in range(n):
x -= a_sorted[i]
if x > 0 and i <= n-2:
c += 1
elif x == 0:
c += 1
else:
break
print(c)
|
p03254 | s386895103 | Accepted | from itertools import accumulate
import bisect
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = list(accumulate(a))
ans = bisect.bisect_right(c, x)
if not ans:
print(ans)
else:
print(ans if c[N - 1] >= x else ans - 1) |
p03254 | s049124437 | Accepted | N,x=map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
a.sort()
for i in a:
if x >= i:
x -= i
cnt +=1
else:
print(cnt)
exit()
if x ==0:
print(cnt)
else:
print(cnt-1) |
p03254 | s602175253 | Accepted | N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
total = 0
index = 0
for i in range(N):
total += num_list_s[i]
if total > X:
break
else:
index += 1
if sum(num_list) < X:
print(index-1)
else:
print(index) |
p03254 | s576293992 | Accepted | n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n-1):
if l[i] <= x:
x -= l[i]
ans += 1
else:
if l[-1] == x:
ans += 1
print(ans) |
p03254 | s211983481 | 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:
break
else:
if x>0:
ans-=1
print(ans) |
p03254 | s575057910 | Accepted | N, x = list(map(int, input().split()))
A = list(map(int, input().split()))
#print(N, x)
A.sort()
#print(A)
cnt = 0
for a in A:
if x >= a:
x -= a
cnt += 1
else:
break
if cnt == N and x > 0:
cnt = cnt - 1
print(cnt) |
p03254 | s140473512 | 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
if a[N-1]==x:
happy+=1
print(happy) |
p03254 | s493756974 | Accepted | import numpy as np
N, x = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
cumsum = A.cumsum()
if cumsum[-1] < x:
print(N - 1)
exit()
ans = 0
for i in range(N):
if cumsum[i] <= x:
ans = i + 1
print(ans)
|
p03254 | s983344700 | Accepted | N,x = map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(N):
if x == 0:
break
if x >= a[i]:
ans+=1
x-=a[i]
else:
x = 0
if x != 0:
ans -= 1
print(max(0,ans))
|
p03254 | s932408043 | Accepted | N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
for i, a in enumerate(A):
x -= a
if x == 0:
print(i+1)
exit()
elif x < 0:
print(i)
exit()
print(N-1) |
p03254 | s177902940 | Accepted | N, x, *A = map(int, open(0).read().split())
A.sort()
ans = 0
for a in A[:-1]:
if x - a >= 0:
x -= a
ans += 1
else:
break
if x == A[-1]:
ans += 1
print(ans)
|
p03254 | s339570825 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for i in a:
if x >= i:
x -= i
cnt += 1
else:
break
if x != 0 and cnt != 0 and cnt == n:
cnt -= 1
print(cnt) |
p03254 | s402630213 | Accepted | n,x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
x -= a[i]
if (x < 0):
print(i)
break
else:
if (x != 0):
print(n - 1)
else:
print(n) |
p03254 | s724694204 | Accepted | #coding:utf-8
n, x = map(int, input().split())
a = list(map(int, input().split()))
child = sorted(a)
for i in range(n):
x -= child[i]
if x < 0:
break
elif x == 0:
print(i+1)
exit()
print(i) |
p03254 | s825532301 | Accepted | n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
a.sort()
for i in range(n):
ai = a[i]
if i==n-1:
if ai==x:
ans+=1
else:
pass
break
if ai<=x:
ans+=1
x-=ai
print(ans) |
p03254 | s482743740 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
maxcandy = 0
X = x
A = sorted(a)
for i in range(N):
maxcandy += A[i]
for i in range(N):
if x >= A[i]:
x = x - A[i]
count += 1
else:
break
if maxcandy < X:
print(count-1)
else:
print(count)
|
p03254 | s693566544 | Accepted | N, x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(len(A)):
x = x-A[i]
if x >= 0:
ans += 1
else:
break
if x > 0:
ans -= 1
print(ans) |
p03254 | s030602198 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
if sum(a)==x:
print(n)
exit()
else:
for i in range(n-1):
if a[i]<=x:
x-=a[i]
cnt+=1
print(cnt) |
p03254 | s414224783 | Accepted | N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
Q=0
for i in range(N):
if x>=a[i] and i!=N-1:
Q+=1
x=x-a[i]
elif i==N-1 and x==a[i]:
Q+=1
print(Q) |
p03254 | s869903185 | Accepted | N, X = map(int,input().split())
S = map(int,input().split())
S = sorted(S)
cnt = 0
for s in S:
X -= s
if X >= 0:
cnt += 1
else:
break
if X > 0:
cnt -= 1
print(cnt)
|
p03254 | s622728046 | Accepted | from sys import stdin
n, x = [int(x) for x in stdin.readline().split()]
a_lst = sorted([int(x) for x in stdin.readline().split()])
s = 0
for i, a in enumerate(a_lst):
s += a
if s > x:
print(i)
exit()
if s == x: print(i+1)
else: print(i) |
p03254 | s345208948 | Accepted | #!/usr/bin/env python3
def main():
N, x, *A = map(int, open(0).read().split())
A.sort()
for i in range(N):
x -= A[i]
if x == 0:
print(i + 1)
break
elif x < 0:
print(i)
break
else:
# γ‘γγγ©Nεγγγγͺγγ¨εγΉγͺγζ²γγεγ©γγγ‘
print(N - 1)
main()
|
p03254 | s993830673 | Accepted | N, x = map(int, input().split())
a = sorted(map(int, input().split()))
ans = 0
for i in range(N):
x -= a[i]
if x < 0:
break
else:
ans += 1
print(ans if x <= 0 else ans-1) |
p03254 | s292555456 | Accepted | N, x = map(int, input().split())
A = sorted(map(int, input().split()))
count = 0
for i in range(len(A)):
if (x >= 0):
x = x - A[i]
count += 1
else:
break
if (x > 0):
print(count - 1)
elif(x == 0):
print(count)
elif(x < 0):
print(count - 1)
|
p03254 | s747014642 | Accepted | N,x = map(int,input().split())
a = sorted(map(int,input().split()),reverse=False)
ans = 0
if x > sum(a):
print(N - 1)
else:
for i in a:
x -= i
if x >= 0:
ans += 1
print(ans) |
p03254 | s022981808 | Accepted | a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
i=0
total=0
while True:
if b<c[i]:
print(total)
break
elif i==a-1:
if b==c[i]:
print(total+1)
else:
print(total)
break
else:
total+=1
b=b-c[i]
i+=1 |
p03254 | s755168520 | Accepted | n, x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
count = 0
for i in a:
if x - i >= 0:
x -= i
count += 1
else:
break
if x != 0:
count -= 1 if count == n else 0
print(count) |
p03254 | s769427033 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=False)
count = 0
for i in range(n):
if x>=a[i]:
count += 1
x -= a[i]
else:
break
if (x!=0)and(count==n):
count -= 1
print(count) |
p03254 | s059722099 | Accepted | 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 a[i] <= x:
ans += 1
x -= a[i]
if i == N-1 and a[i] == x:
ans += 1
print(ans) |
p03254 | s991689669 | Accepted | N,x=map(int,input().split())
A=list(map(int,input().split()))
A_1=sorted(A)
num=0
total=0
if A_1[0]>x:
num=0
elif sum(A_1)>=x:
for i in range(N):
total+=A_1[i]
if total==x:
num+=1
break
elif total>x:
break
else:
num+=1
else:
num=N-1
print(num)
|
p03254 | s161161474 | Accepted | N,X= map(int,input().split())
A = [int(a) for a in input().split()]
A.sort()
tmp = 0
ans = 0
for a in A:
tmp+=a
if tmp<=X:
ans+=1
if ans==N and tmp<X:
ans-=1
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.