problem_id stringclasses 100
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 6 806 |
|---|---|---|---|
p03254 | s072351786 | Accepted | N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
for a in A[:-1]:
if a <= x:
ans += 1
x -= a
print(ans + 1 if A[-1] == x else ans) |
p03254 | s941395319 | Accepted | N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
for i in range(len(A)):
if x-A[i]<0:
print(i)
exit()
else:
x-=A[i]
if x==0:print(N)
else:print(N-1)
|
p03254 | s955327573 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in range(len(a)):
if x - a[i] >= 0:
x -= a[i]
count += 1
else:
break
if count == N and x > 0:
print(count - 1)
else:
print(count) |
p03254 | s629844219 | Accepted | N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cnt = 0
sum_x = 0
for i in range(N):
if(i == N-1):
if((x-sum_x) == A[N-1]):
cnt += 1
break
if(sum_x+A[i] <= x):
sum_x += A[i]
cnt += 1
else:
break
print(cnt) |
p03254 | s891993005 | Accepted | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
def main(n, x, a):
cnt = 0
for j, i in enumerate(a):
x -= i
if x < 0:
break
elif j == n-1 and x > 0:
break
cnt += 1
return cnt
n, x = map(int, readline().split())
a = np.sort(np.array(readline().split(), np.int64))
print(main(n, x, a))
|
p03254 | s898068416 | Accepted | N,x = map(int,input().split())
a = list(map(int, input().split()))
a.sort()
cnt=0
for i in a:
x-=i
if x>=0:
cnt+=1
if x>0:
cnt-=1
print(cnt) |
p03254 | s291887911 | Accepted | n, x = map(int, input().split())
A = sorted([int(i) for i in input().split()])
# print(A)
cnt = 0
for e in A:
if e <= x:
x = x - e
cnt += 1
if cnt == n and x > 0:
print(cnt-1)
else:
print(cnt)
|
p03254 | s423831918 | Accepted | n,x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
count = 0
s = 0
for i in range(n):
if i == n-1:
if x == a[i]:
count += 1
else:
s += a[i]
if x > a[i]:
x -= a[i]
count += 1
elif x < a[i]:
break
else:
count += 1
break
print(count) |
p03254 | s108399508 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
p = x
a.sort()
count = 0
for i in a:
if x - i >= 0:
x -= i
count += 1
if x > 0 and count != 0 and p > sum(a):
count -= 1
print(count) |
p03254 | s410335490 | Accepted | N, x = map(int,input().split())
a = list(map(int,input().split()))
count = 0
a_new = sorted(a)
for i in range(0, N):
count += a_new[i]
if x == count:
index = i + 1
break
if count > x:
index = i
break
index = i
print(str(index)) |
p03254 | s472030576 | Accepted | n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
for i in range(n):
x-=a[i]
if x<0:
break
else:
if x==0:
i+=1
print(i) |
p03254 | s902952776 | Accepted | N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
if sum(A) < x:
print(N-1)
exit()
A = [1] + A
ans = 0
while A[-1] <= x:
x -= A[-1]
A.pop()
ans += 1
print(ans) |
p03254 | s777543439 | Accepted | N,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
s = [sum(a[:i+1]) for i in range(N)]
if s[-1] == x:
print(N)
exit()
else:
for i in range(N-1):
if s[i] > x:
print(i)
exit()
print(N-1) |
p03254 | s093728307 | Accepted | N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
ans = 0
for a in A:
x = x-a
if x<0:
break
ans+=1
print(ans-(x>0)) |
p03254 | s099743674 | Accepted | import sys
input = lambda :sys.stdin.readline().rstrip()
N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
if x > sum(A):
cnt = -1
else:
cnt = 0
for i in range(N):
if x - A[i] >= 0:
cnt += 1
x -= A[i]
if x <= 0:
break
#print(cnt, x)
print(cnt) |
p03254 | s775402031 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
if x == sum(a):
ans = n
elif x > sum(a):
ans = n-1
else:
for i in range(n):
if x - a[i] >= 0:
x -= a[i]
ans += 1
else:
break
print(ans) |
p03254 | s630064177 | Accepted | def resolve():
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
a = sorted(a)
for i in range(n):
if x < 0:
break
x -= a[i]
ans += 1
if x != 0:
ans -= 1
print(ans)
resolve() |
p03254 | s420749535 | Accepted | N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
for a in A[:-1]:
if x - a >= 0:
x -= a
ans += 1
print(ans + (A[-1] == x))
|
p03254 | s398842769 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
a.sort()
cnt=0
for i in range(n):
if a[i]<=x:
x-=a[i]
if i==n-1 and x!=0:
break
cnt+=1
else:
break
print(cnt)
|
p03254 | s147502989 | Accepted | N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
res = 0
for a in A:
if a > X:
break
res += 1
X -= a
else:
if X > 0:
res -= 1
print(max(res, 0)) |
p03254 | s369587104 | 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] >=0:
ans += 1
x -= a[i]
else:
break
if x == 0 or ans < N:
print(ans)
else:
print(ans-1) |
p03254 | s933461446 | Accepted | N,x=map(int,input().split())
a=list(map(int,input().split()))
a_sort=sorted(a,reverse=False)
tot=0
if sum(a)==x:
print(len(a))
elif sum(a)<x:
print(len(a)-1)
else:
for i in range(N):
tot+=a_sort[i]
if tot==x:
print(i+1)
break
elif tot<x:
pass
elif tot>x:
print(i)
break |
p03254 | s864364818 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
sort_a = sorted(a)
count = 0
if x > sum(a):
count-=1
for i in sort_a:
if x >= i:
count+=1
x-=i
else:
print(count)
exit()
print(count)
|
p03254 | s763546889 | Accepted | # A - Candy Distribution Again
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 or (i==N-1 and x!=0):
break
ans += 1
print(ans) |
p03254 | s209095034 | Accepted | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
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)
if __name__ == '__main__':
main() |
p03254 | s627798423 | Accepted | from bisect import bisect_right
from itertools import accumulate
n, x = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
arr = list(accumulate(arr))
happy = bisect_right(arr, x)
if happy == n:
if arr[-1] != x:
happy -= 1
print(happy) |
p03254 | s187845046 | 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 | s360333557 | Accepted | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
res = 0
for i in range(n):
if i == n - 1 and A[i] < x:
continue
if A[i] <= x:
x -= A[i]
res += 1
print(res)
if __name__ == '__main__':
resolve()
|
p03254 | s751855428 | Accepted | #!/usr/bin/env python
# coding: utf-8
# In[17]:
N,x = map(int, input().split())
a = list(map(int, input().split()))
# In[18]:
a_sum = sum(a)
if a_sum == x:
print(N)
elif a_sum < x:
print(N-1)
else:
for i in range(N):
if x < sum(sorted(a, reverse=False)[:i+1]):
print(i)
break
# In[ ]:
|
p03254 | s456634173 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
num=0
for i in range(n):
num+=a[i]
if num>x:
print(i)
exit()
if num==x:
print(n)
else:
print(n-1) |
p03254 | s675897932 | Accepted | N, x = map(int, input().split())
A_list = list(map(int, input().split()))
A_list = sorted(A_list)
for i in range(N):
x -= A_list[i]
if x <= 0:
break
print(i+1) if x == 0 else print(i) |
p03254 | s182977025 | Accepted |
N, x = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
ans = []
for i in A:
x -= i
#print(ans, x)
if x >= 0:
ans.append(i)
else:
break
if x > 0:
print(len(ans)-1)
else:
print(len(ans)) |
p03254 | s920611402 | Accepted | #! /usr/bin/env python3
import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
N, x, *A = map(int, read().split())
A = sorted(A)
cnt = 0
for a in A[:-1]:
if x >= a:
cnt += 1
x -= a
if x == A[-1]:
cnt += 1
print(cnt)
|
p03254 | s748267214 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
a.sort()
for i in a:
x-=i
if x>0:
ans+=1
continue
elif x==0:
ans+=1
break
else:
break
if ans==n:
if x!=0:
ans-=1
print(ans)
|
p03254 | s956369362 | Accepted | N, x = map(int, input().split())
array = list(map(int, input().split()))
a = sorted(array, reverse=False)
#print(a)
answer = 0
for i in range(N):
x -= a[i]
if x < 0:
break
answer += 1
if i == N-1 and x != 0:
answer -= 1
break
if x < a[i]:
break
print(answer)
|
p03254 | s111529323 | Accepted | n,x = map(int,input().split())
al = list(map(int,input().split()))
al.sort()
c = 0
for a in al:
if x >= a:
c += 1
x -= a
if x > 0 and c > 0:
c -= 1
print(c) |
p03254 | s102445921 | Accepted | import sys
inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())
n, x = inintm()
A = inintl()
A.sort()
ans = 0
for i in range(n-1):
if x - A[i] >= 0:
ans += 1
x -= A[i]
if A[-1] == x:
ans += 1
print(ans)
|
p03254 | s181157669 | Accepted | N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
if x>=2*sum(A):
print(0)
else:
ind = N
for i in range(N):
x -= A[i]
if x<0:
ind = i
break
if ind==N and x>0:
A = sorted(A,reverse=True)
for i in range(N):
x -= A[i]
if x<0:
ind -= 1
break
print(ind) |
p03254 | s787204476 | Accepted | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n):
k -= a[i]
if k >= 0:
cnt += 1
else:
break
if k > 0:
cnt -= 1
print(cnt) |
p03254 | s283495585 | Accepted | n,x=map(int,input().split())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in l:
x-=i
ans+=1
if x<0:
break
if x!=0 and ans>0:
print(ans-1)
else:
print(ans) |
p03254 | s073043984 | Accepted | n, a = map(int, input().split())
b = list(map(int, input().split()))
b.sort()
c = 0
for i in range(n):
if a < b[i] or (i == n - 1 and b[i] != a):
break
a -= b[i]
c += 1
print(c) |
p03254 | s230636466 | Accepted | n, x = list(map(int, input().split()))
lista = list(map(int, input().split()))
lista.sort()
snack = 0
for i in range(n):
if lista[i] + snack <= x:
snack += lista[i]
else:
print(i)
break
else:
if snack == x:
print(n)
else:
print(n - 1) |
p03254 | s500779302 | Accepted | # -*- coding:utf-8 -*-
N,x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
a.sort()
while x > 0:
if cnt >= N:
if x > 0:
cnt -= 1
break
else:
break
elif a[0] > x:
break
else:
tmp = a.pop(0)
x -= tmp
cnt+=1
print(cnt)
|
p03254 | s483350380 | Accepted | if __name__ == "__main__":
n, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) == x:
print(n)
exit()
a.sort()
ans = 0
for i in range(n):
if sum(a[:i+1]) <= x:
ans = i+1
else:
print(i)
exit()
if sum(a[:ans]) == x:
print(ans)
else:
print(ans-1)
|
p03254 | s407598244 | 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
if x == lst[N-1]:
cnt +=1
print(cnt) |
p03254 | s382667433 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
a.sort()
for idx, v in enumerate(a):
if v <= x:
x -= v
if idx == N - 1:
if x == 0:
count += 1
else:
count +=1
print(count)
|
p03254 | s452384754 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
s_a = sorted(a)
cnt = 0
for i in range(N-1):
if(s_a[i] <= x):
cnt += 1
x -= s_a[i]
if(s_a[N-1] - x == 0):
cnt += 1
print(cnt) |
p03254 | s610693763 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
s=0
for i in range(n):
if s+a[i]<=x:
ans+=1
s+=a[i]
if s<x:
print(ans-1)
else:
print(ans) |
p03254 | s842227605 | Accepted | n,x = map(int, input().split())
line = list(map(int, input().split()))
line.sort()
ans = 0
for i in range(n):
x -= line[i]
if x < 0:
break
else:
ans += 1
if i == n-1 and x != 0:
ans -= 1
print(ans)
|
p03254 | s498729257 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
res=0
i=0
a.sort()
while 0<x and i < n:
if a[i] <= x:
res+=1
x-=a[i]
i+=1
if 0 < x:
print(res-1)
else:
print(res) |
p03254 | s412992916 | Accepted | n, x = map(int, input().split())
lst = [0] + sorted(list(map(int, input().split())))
for i in range(n):
lst[i + 1] += lst[i]
for i in range(n):
if lst[i] <= x < lst[i + 1]:
print(i)
exit()
if x == lst[n]:
print(n)
else:
print(n - 1) |
p03254 | s294878582 | Accepted | N, x=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
i=0
while i<N and x>=a[i]:
x-=a[i]
i+=1
if i==N and x>0:
i-=1
print(i) |
p03254 | s598279047 | Accepted | N,x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
res = 0
for i in range(N):
x -= a[i]
if x < 0:
break
res += 1
if x > 0:
res -= 1
print(res) |
p03254 | s437960284 | Accepted | N,x = map(int,input().split())
a = map(int,input().split())
ret = 0
for i,n in enumerate(sorted(a)):
if i == N-1 and n == x:
x -= n
ret += 1
elif i < N-1 and n <= x:
x -= n
ret += 1
else:
break
print(ret) |
p03254 | s681602946 | Accepted | def resolve():
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Acouont = 0
ans = 0
if sum(A) < x:
print(N-1)
else:
for i in range(N):
Acouont = Acouont + A[i]
#print (Acouont)
if Acouont > x:
break
ans += 1
print(ans)
resolve() |
p03254 | s450869555 | Accepted | def resolve():
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted(a)
ans = 0
for _a in a[:-1]:
x = x - _a
if x >= 0:
ans += 1
if x == a[-1]:
ans += 1
print(ans)
resolve()
|
p03254 | s569925016 | Accepted | N,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
if sum(a)==x:
print(N)
else:
a.sort()
s=0
i=0
while True:
s+=a[i]
if i==N-1 and s!=x:
print(N-1)
break
if s>x:
print(i)
break
i+=1
if i>=N:
print(N)
break
|
p03254 | s450780785 | Accepted | from bisect import bisect_left
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a_cs = [0] * (n + 1)
for i in range(n):
a_cs[i + 1] = a_cs[i] + a[i]
idx = bisect_left(a_cs, x)
if idx == n + 1:
ans = n - 1
elif a_cs[idx] > x:
ans = idx - 1
else:
ans = idx
print(ans)
|
p03254 | s898003846 | 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]:
ans+=1
x-=a[i]
else:
break
if ans==N:
if x==0:
pass
else:
ans-=1
print(ans) |
p03254 | s918515708 | Accepted | #!/usr/bin/env python
n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
if x < a[0]:
print(0)
exit()
cnt = 0
al = False
for i in range(n):
if x >= a[i]:
x -= a[i]
cnt += 1
else:
break
if i == n-1:
al = True
if al:
if x > 0:
ans = cnt-1
else:
ans = cnt
else:
ans = cnt
print(ans)
|
p03254 | s897894224 | Accepted | [N, x] = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
count = 0
i = 0
while x > 0 and i <= len(a):
x -= a[i]
if i == len(a)-1:
if x != 0:
break
if x >= 0:
count += 1
i += 1
print(count) |
p03254 | s459074251 | Accepted | N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt = 0
for elem in a:
if x >= elem:
cnt += 1
x -= elem
else:
break
print(cnt if cnt != N or x == 0 else cnt - 1)
|
p03254 | s109460944 | Accepted | n,x=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
a.sort()
s=0
if sum(a)==x:
ans=n
elif sum(a)<x:
ans=n-1
else:
for i in range(n):
if sum(a[:i+1])>x:
ans=i
break;
print(ans) |
p03254 | s998205321 | Accepted | import math
N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
#print(a)
conf=0
for i in range(N):
if i==N-1:
if a[i]==x:
conf=conf+1
else:
if a[i]<=x:
conf=conf+1
x=x-a[i]
else:
break
print(conf) |
p03254 | s559913034 | Accepted | N, x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt = 0
for i, child in enumerate(a):
if x == 0:
break
if child == x:
cnt += 1
break
if child < x:
# 最後の要素か判定
if i == len(a) - 1:
break
x -= child
cnt += 1
print(cnt) |
p03254 | s848123526 | Accepted | N, x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
f=0
i=0
while x>=a[i]:
x=x-a[i]
i=i+1
f=f+1
if i==N:
break
if i==N and x>0:
print(f-1)
else:
print(f) |
p03254 | s521406886 | Accepted | import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
n, x = map(int, readline().split())
a = list(map(int, readline().split()))
a.sort()
rem = x
ans = 0
for i in range(n - 1):
if rem >= a[i]:
rem -= a[i]
ans += 1
if a[n-1] == rem:
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
p03254 | s668962396 | Accepted | #AGC027-A
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt = 0
flg = True
for i in range(n):
if a[i] <= x:
x -= a[i]
cnt += 1
else:
flg = False
break
if flg and x != 0:
cnt -= 1
print(cnt)
|
p03254 | s020031199 | Accepted | import sys
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
c = 0
p = x
for i in range(n-1):
if a[i] > p:
print(c)
sys.exit()
else:
c += 1
p -= a[i]
if a[-1] == p:
print(n)
else:
print(n-1) |
p03254 | s616709714 | Accepted | n,x = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort()
count = 0
for i in range(n):
x = x - a_list[i]
count += 1
if x <= 0:
break
if x == 0:
print(count)
else:
print(count-1) |
p03254 | s707356214 | 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]:
ans += 1
x -= a[i]
if x > 0 and ans >= n:
ans -= 1
print(ans) |
p03254 | s635252339 | Accepted | def main():
n, x = map(int, input().split())
num_list = list(map(int, input().split()))
ans = 0
num_list.sort()
for num in num_list:
if x - num >= 0:
x -= num
ans += 1
else:
break
if ans == n and x > 0:
ans -= 1
print(ans)
if __name__ == '__main__':
main()
|
p03254 | s616031847 | Accepted | N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
cnt=0
for i in range(N):
if A[i]<=X:
X-=A[i]
cnt+=1
else:
break
if X>0 and cnt==N:
cnt-=1
print(cnt)
|
p03254 | s094880476 | Accepted | N, x = map(int, input().split())
a_li = list(map(int, input().split()))
a_li.sort()
ans = 0
for a in a_li :
if x >= a :
ans += 1
x -= a
else :
x = 0
break
if x != 0 :
ans -= 1
print(max(0, ans))
|
p03254 | s467017984 | Accepted | 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
else:
if x != 0:
ans -= 1
print(ans)
|
p03254 | s044947661 | Accepted | n, x = map(int, input().split())
nums = sorted(list(map(int, input().split())))
count = 0
for i, num in enumerate(nums):
if (i < n-1 and num <= x) or (i == n-1 and num == x):
count += 1
x -= num
else:
break
print(count) |
p03254 | s203723196 | 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 | s108461036 | Accepted | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
for i, v in enumerate(a):
x -= v
if i == n - 1:
if x == 0:
ans += 1
break
else:
if x >= 0:
ans += 1
continue
else:
break
print(ans)
|
p03254 | s958320857 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
res = 0
for aa in a:
x -= aa
if x < 0:
print(res)
exit()
res += 1
if x == 0:
print(N)
else:
print(N - 1) |
p03254 | s372363820 | Accepted | n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
ans = 0
for i,h in enumerate(a[:-1]):
x-=h
if x>=0:ans+=1
if x==a[-1]:ans+=1
print(ans) |
p03254 | s317738064 | Accepted | # A - Candy Distribution Again
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 or (ans==N-1 and x!=0):
break
ans += 1
print(ans) |
p03254 | s811922833 | 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-=a[i]
count+=1
else:
print(count)
exit()
if x>0:
print(count-1)
else:
print(count) |
p03254 | s231194251 | 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]:
if i+1 == N:
print(N-1)
exit()
else:
ans += 1
x -= A[i]
elif x == A[i]:
ans += 1
print(ans)
exit()
else:
print(ans)
exit() |
p03254 | s253209841 | Accepted | N,x = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
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 | s072964063 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
rem = x
give = 0
for i in range(n):
rem -= a[i]
give += 1
if rem < 0:
break
if rem != 0:
give -= 1
print(give)
|
p03254 | s613156843 | 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
if i == n-1:
if x > 0:
break
ans += 1
print(ans) |
p03254 | s664112854 | Accepted | N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
c = 0
for i in A:
x -= i
if x >= 0:
c += 1
else:
break
if x > 0:
c -= 1
print(c)
|
p03254 | s919241367 | Accepted | n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
SUM = 0
for i in range(n):
SUM += A[i]
if SUM > x:
print(i)
break
elif SUM == x:
print(i + 1)
break
else:
print(n - 1)
|
p03254 | s343898198 | Accepted | N,X = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
m = sum(a)
count = 0
S=0
if m == X:
print(N)
elif m < X:
print(N-1)
elif a[0] > X:
print(0)
else:
for i in a:
if S <= X:
S = S + i
count = count + 1
else:
print(count-1) |
p03254 | s586126724 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if sum(a) < x:
print(N - 1)
elif sum(a) > x:
ans = 0
ans_ = 0
for a in a:
ans_ += a
if ans_ > x:
break
ans += 1
print(ans)
elif sum(a) == x:
print(N)
|
p03254 | s277547494 | 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:
n=i
break
if x <=0:
print(n)
elif x > 0:
print(n-1)
|
p03254 | s968461543 | Accepted | n,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cnt = 0
if x > sum(A):
print(n-1)
else:
for i in range(n):
if (x - A[i]) >= 0:
x -= A[i]
cnt += 1
else:
break
print(cnt) |
p03254 | s239091562 | 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:
break
else:
ans += 1
if 0 < x:
ans -= 1
print(max(ans, 0))
|
p03254 | s575844755 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
a.sort()
for i in a:
if a.index(i) == n - 1:
if i == x:
cnt += 1
elif i <= x:
x -= i
cnt += 1
else:
break
print(cnt) |
p03254 | s087299352 | Accepted | n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
tmp=x
ans=0
for i in a[:-1]:
tmp=tmp-i
if tmp>=0:
ans+=1
if tmp==a[-1]:
ans+=1
print(ans) |
p03254 | s349465727 | Accepted | from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from bisect import bisect
from itertools import accumulate
n,x=nii()
a=lnii()
a.sort()
b=list(accumulate(a))
if b[-1]<x:
print(n-1)
else:
inx=bisect(b,x)
print(inx) |
p03254 | s023710809 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
c = 0
ans = 0
for i in range(N):
if c + a[i] <= x:
c += a[i]
ans += 1
else:
print(ans)
exit()
if c == x:
print(N)
else:
print(N-1) |
p03254 | s960180738 | Accepted | N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cnt=0
for i in range(N):
#print(i,a[i],x)
if a[i]<=x:
if i==N-1:
if x==a[i]:
cnt += 1
else:
x -= a[i]
cnt += 1
else:
break
print(cnt) |
p03254 | s142438886 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
M = []
cn = 0
for i in range(N):
x = x - a[i]
if x >= 0 and i != N-1:
cn = cn + 1
elif x < 0:
print(cn)
break
elif i == N-1:
if x == 0:
cn = cn + 1
print(cn)
break
else:
print(cn)
break |
p03254 | s815265303 | Accepted | from sys import stdin
import math
[N, x] = list(map(int, stdin.readline().rstrip().split()))
a = list(map(int, stdin.readline().rstrip().split()))
a_sorted = sorted(a)
count=0
for i in range(N):
#x -= a_sorted[i]
x = x - a_sorted[i]
if x >=0:
count += 1
else:
break
if x > 0:
count -= 1
print(count)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.