problem_id stringclasses 100
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 6 806 |
|---|---|---|---|
p03254 | s972295120 | 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]:
ans += 1
x -= a[i]
else:
break
if a[N - 1] == x:
ans += 1
print(ans)
|
p03254 | s611840703 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort(key=int)
ans=0
for i in range(n):
x=x-a[i]
if x<0:
x=x+a[i]
else:
ans+=1
if ans==n:
if x>0:
print(ans-1)
else:
print(ans)
else:
print(ans) |
p03254 | s471928003 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
ans=0
for i in range(n):
cnt+=a[i]
if cnt==x:
ans=i+1
break
elif cnt>x:
ans=i
break
elif i==n-1:
ans=n-1
print(ans) |
p03254 | s100962711 | Accepted | 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) |
p03254 | s606464016 | Accepted | N, x = map(int, input().split())
a = sorted(map(int, input().split()))
cnt = 0
for i in range(N):
x -= a[i]
if x < 0:
break
else:
cnt += 1
print(cnt if x <= 0 else cnt-1) |
p03254 | s276563680 | Accepted | import math
#n, a, b= map(int, input().split())
n, x = map(int, input().split())
a = list(map(int, input().split()))
#s = list(str(input()))
#n = int(input())
#a = [""]*n
#for i in range(n):
# a[i] = str(input())
#for i in range(n):
a.sort()
tot = 0
for i in range(n):
tot = tot + a[i]
if(x < tot):
print(i)
break
if(x == tot):
print(i+1)
if(x > tot):
print(i) |
p03254 | s758176479 | Accepted | n, x = list(map(int, input().split()))
a_list = sorted(sorted(map(int, input().split())))
# a_listの総和が全お菓子の数と同じなら答えはN, そうでないならN-1以下
if sum(a_list) == x:
print(n)
exit()
ans = 0
for i, a in enumerate(a_list):
# 答えはN-1以下
if i == len(a_list) - 1:
break
if x < a:
break
x -= a
ans += 1
print(ans)
|
p03254 | s837056414 | Accepted | N,x = map(int,input().split())
li = list(map(int,input().split()))
newLi = sorted(li)
ans = 0
for i in range(len(newLi)):
if x - newLi[i] < 0:
break
if i == (len(newLi) - 1) and x != newLi[i]:
break
x -= newLi[i]
ans += 1
print(ans) |
p03254 | s901133066 | Accepted | n,x = map(int,input().split())
l = sorted(list(map(int,input().split())))
pe = 0
for i in l:
if x-i>=0:
x -= i
pe += 1
else:
break
if x!=0 and n==pe:
print(pe-1)
else:
print(pe) |
p03254 | s434013818 | Accepted | N,n=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=0
i=0
while A[i]<=n:
if i==N-1:
if n==A[i]:
ans+=1
break
else:
ans+=1
n-=A[i]
i+=1
print(ans) |
p03254 | s658897081 | Accepted | n, x = [int(_) for _ in input().split()]
a = sorted([int(_) for _ in input().split()])
ans = 0
for i in range(n):
x -= a[i]
if x < 0:
break
else:
ans += 1
print(ans - 1 if x > 0 else ans) |
p03254 | s912343326 | Accepted | N,x = input().split()
A = input().split()
a = []
for i in range(int(N)):
a.append(int(A[i]))
a.sort()
X = int(x)
idx = 0
while X>0 and idx<int(N):
X = X-a[idx]
idx+=1
if X==0:
idx+=1
print(idx-1) |
p03254 | s225677108 | Accepted | N, X = map(int, input().split())
lists = list(map(int, input().split()))
if X - sum(lists) == 0:
print(len(lists))
exit()
count = 0
for num in sorted(lists):
X -= num
if X >= 0:
count += 1
if X < 0:
print(count)
else:
print(count - 1) |
p03254 | s181716756 | Accepted | n, x = map(int, input().split())
num_lists = list(map(int, input().split()))
num_lists.sort()
cnt = 0
sum = 0
for i in range(len(num_lists)):
sum += num_lists[i]
if sum <= x:
cnt = i+1
else:
x = 0
cnt = i
break
x -= sum
if 0 < x:
cnt -= 1
print(cnt) |
p03254 | s803814283 | Accepted | N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
total=0
j=0
ssum=sum(a)
if ssum>=x:
for i in range(N):
total+=a[i]
if total>x:
break
j+=1
print(j)
else:
print(N-1)
|
p03254 | s441188342 | Accepted | n,x=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
ans=ac=0
for i in l:
ac+=i
if x>=ac:
ans+=1
if ac<x:
ans-=1
print (ans) |
p03254 | s580713046 | 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 cnt == N and x!=0:
cnt -=1
print(cnt)
|
p03254 | s083308980 | Accepted | N, x = map(int, input().split())
list_a = [int(x) for x in input().split()]
list_a.sort()
total = sum(list_a)
if x < list_a[0] :
print(0)
exit()
if x > total :
print(len(list_a)-1)
exit()
ans = 0
for i in range(N) :
if list_a[i] <= x :
x -= list_a[i]
ans += 1
print(ans)
|
p03254 | s353895469 | Accepted | N,x=map(int,input().split())
a=list(map(int,input().split()))
result=0
a.sort()
for i in range(N):
n=a.pop(0)
if x>=n:
x-=n
result+=1
else:
break
else:
if not x==0:
result-=1
print(result) |
p03254 | s488899087 | Accepted | N, x = map(int,input().split())
a = sorted(map(int,input().split()))
A = sum(a)
if x > A:
print(N-1)
elif x == A:
print(N)
else:
t = 0
for n in range(N):
t += a[n]
if t > x:
print(n)
break |
p03254 | s662465107 | Accepted | n,x = map(int,input().split())
a = [int(x.strip()) for x in input().split()]
a_sorted = sorted(a)
ch,ans = 0,0
for i in range(n):
ch = sum(a_sorted[:i+1])
if ch < x:
ans += 1
elif ch == x:
ans += 1
break
else:
break
if n == ans and sum(a) < x:
ans -= 1
print(ans) |
p03254 | s000761704 | Accepted | try:
N, x = map(int, input().split())
a = list(map(int, input().split()))
a_ = sorted(a)
cnt = 0
for i in range(len(a_)-1):
if a_[i]<=x:
cnt += 1
x = x-a_[i]
if a_[len(a_)-1]-x==0:
cnt += 1
print(cnt)
except EOFError:
pass |
p03254 | s129563170 | Accepted | n,x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
ans = 0
for aa in a[:-1]:
x -= aa
if x >= 0:
ans += 1
else:
break
if a[-1] == x:
print(ans+1)
else:
print(ans) |
p03254 | s077497164 | Accepted | N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
m=0
for i in a:
if i<=x:
m+=1
x-=i
else:
break
if N==m and x:
m-=1
print(m) |
p03254 | s353865890 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
cnt = 0
for a_ in a:
cnt += 1
if a_ <= x:
x -= a_
elif a_ > x:
x -= a_
break
print(cnt if x == 0 else cnt - 1) |
p03254 | s361378082 | Accepted | N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
c = 0
rx = x
for i in range(N):
if a[i] > rx or (i == N-1 and rx != a[i]):
print(c)
exit()
c += 1
rx -= a[i]
print(N) |
p03254 | s272908712 | Accepted | N, x = [int(x) for x in input().strip().split()]
an = sorted([int(a) for a in input().strip().split()])
cumsum = 0
ans = 0
for i, a in enumerate(an, start=1):
cumsum += a
if cumsum > x:
break
ans = i
else:
if cumsum != x:
ans -= 1
print(ans) |
p03254 | s557483184 | Accepted | N,x = map(int,input().split())
As = list(map(int,input().split()))
As.sort()
cnt = 0
ans = 0
while x > 0:
if cnt + 1 == N and x != As[cnt]:
x = 0
elif x >= As[cnt]:
x -= As[cnt]
ans+=1
cnt += 1
else:
print(ans) |
p03254 | s241012141 | Accepted | n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
if sum(a) == x:
print(n)
exit()
for i in range(n - 1):
if x >= a[i]:
ans += 1
x -= a[i]
print(ans) |
p03254 | s811529613 | Accepted | import sys
import collections
import bisect
def main():
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
k = 0
ans = 0
for i in range(n):
k += a[i]
if k > x:
print(ans)
return
ans += 1
print(ans if sum(a) == x else ans - 1)
if __name__ == '__main__':
main()
|
p03254 | s471108453 | Accepted | N, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
ans = 0
for i in a:
if x >= i:
ans += 1
x -= i
else:
x = 0
break
if x > 0:
ans -=1
print(ans) |
p03254 | s577737813 | Accepted | n, x = map(int, input().split())
res = 0
dat = list(map(int, input().split()))
dat.sort()
for i in range(n):
if x >= dat[i]:
res += 1
x -= dat[i]
else:
break
if x != 0 and res != 0 and res == n:
res -= 1
print(res) |
p03254 | s192671234 | Accepted | import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 18
def main():
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
ans = 0
for a in A:
if x - a >= 0:
x -= a
ans += 1
else:
x = 0
break
if x > 0:
ans -= 1
print(ans)
if __name__ == '__main__':
main() |
p03254 | s242737349 | Accepted | n,x = map(int,input().split())
A= list(map(int,input().split()))
A.sort()
a_sum=0
for i in range(n):
a_sum+= A[i]
if x<a_sum:
print(i)
exit()
if a_sum== x:
print(n)
else:
print(n-1) |
p03254 | s616855244 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans=0
for i in range(N):
x = x-a[i]
if x>=0:
ans+=1
else:
break
if x>0:
print(ans-1)
else:
print(ans) |
p03254 | s419294786 | Accepted | n,x = map(int,input().split())
s = list(map(int,input().split()))
ans = 1
s.sort()
if sum(s)==x:
print(n)
elif sum(s)<x:
print(n-1)
else:
if s[0]>x:
print(0)
else:
for i in range(len(s)):
if sum(s[:i]) <= x < sum(s[:i+1]):
print(i) |
p03254 | s710357278 | Accepted | # Problem A - Candy Distribution Again
# input
n, x = map(int, input().split())
a_list = list(map(int, input().split()))
# initialization
a_list = sorted(a_list)
person_num = 0
# count process
for i in range(len(a_list)):
a = a_list[i]
x = x - a
if x >= 0:
person_num += 1
# output
if x>0:
print(person_num - 1)
else:
print(person_num)
|
p03254 | s327513313 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(); b = 0
for i in range(len(a)):
if x >= a[i]: x -= a[i]; b += 1
else: break
else:
if x > 0: b -= 1
print(b) |
p03254 | s278514952 | Accepted | n, x = map(int, input().split())
li_a = list(map(int, input().split()))
answer = 0
id = -1
for idx, a in enumerate(sorted(li_a)):
if x >= a:
answer += 1
x -= a
id = idx
else:
break
if answer == 0:
print(answer)
elif x == 0:
print(answer)
else:
if id == (n -1):
print(answer - 1)
else:
print(answer)
|
p03254 | s112898183 | Accepted | N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
K=0
for i in range(N-1):
if x>=A[i]:
x-=A[i]
K+=1
if x==A[-1]:
K+=1
print(K)
|
p03254 | s662747321 | Accepted | import sys
input = sys.stdin.readline
N,X=map(int,input().split())
vA=list(map(int,input().split()))
vA.sort()
res=0
for a in vA:
if a<=X:
res += 1
X -= a
else:
break
else:
if X:
res = max(0, res-1)
print(res)
|
p03254 | s265748217 | 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
elif x == i:
cnt += 1
break
else:
break
else:
cnt -= 1
print(cnt)
|
p03254 | s023051660 | Accepted | import itertools
def main():
N,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
accum_a = list(itertools.accumulate(a))
ans = 0
for i in range(N):
if accum_a[i] > x:
break
else:
ans += 1
if accum_a[-1] < x:
ans -= 1
print(ans)
if __name__ == '__main__':
main() |
p03254 | s799312785 | 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 | s103130116 | Accepted | N, x = map(int, input().split())
lis = list(map(int, input().split()))
c = 0
lis.sort()
for i in lis:
x -= i
if x >= 0:
c += 1
else:
break
if x > 0:
c -= 1
print(c)
|
p03254 | s703570304 | Accepted | # -*- coding: utf-8 -*-
n, x = map(int,input().split())
a = [int(i) for i in input().split()]
a.sort()
su = 0
ans = 0
for i in range(n - 1):
su += a[i]
if su <= x:
ans += 1
if su > x:
break
if su + a[-1] == x:
ans += 1
print(ans)
|
p03254 | s597069166 | Accepted | def solve(n, x, A):
A.sort()
count = 0
for i in range(n):
if i < n - 1 and A[i] <= x or i == n - 1 and A[i] == x:
x -= A[i]
count += 1
else:
break
return count
_n, _x = list(map(int, input().split()))
_A = list(map(int, input().split()))
print(solve(_n, _x, _A))
|
p03254 | s033630654 | Accepted | n,x = map(int,input().split())
s = sorted(list(map(int,input().split())))
cnt = 0
for i in range(len(s)):
if(x - s[i] >= 0 ):
if(x < s[i] or (i == len(s)-1 and x != s[i])):
break
else:
cnt += 1
x = x-s[i]
print(cnt) |
p03254 | s368181132 | Accepted | N,X=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort()
cnt=0
if sum(A)<X: cnt-=1
for i,a in enumerate(A):
X-=a
if X>=0:
cnt+=1
else:
break
print(cnt) |
p03254 | s519411331 | Accepted | N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
cnt=0
while x>0:
#print(x)
if x>=A[cnt]:
x-=A[cnt]
cnt+=1
else:
break
if len(A)==cnt:
if x>0:
cnt-=1
break
print(cnt) |
p03254 | s027793616 | Accepted | n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
count = 0
for i in range(n):
if x >= a[i]:
count += 1
x -= a[i]
else:
break
if count == n:
if x != 0:
count -= 1
print(count) |
p03254 | s993267671 | Accepted | n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
cnt = 0
flag = False
for i in a:
if i <= x:
x -= i
cnt += 1
if x == 0:
break
else:
break
else:
cnt -= 1
print(cnt) |
p03254 | s561456442 | Accepted | n, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
pos = -1
for i in range(0, n):
x -= a[i]
if x < 0:
pos = i
break
if pos == -1 and x > 0:
print(n - 1)
elif x == 0:
print(n)
else:
print(pos) |
p03254 | s296985342 | Accepted | n,x = map(int,input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
f = 0
for i in range(n):
if x-a[i]>=0:
ans+=1
x-=a[i]
else:
f = 1
break
if x>0 and f==0:
ans-=1
print(ans) |
p03254 | s028588558 | Accepted | N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
i = 0
while x >= A[i]:
x += -A[i]
i += 1
if i == N:
i = (i-1 if x > 0 else i)
break
print(i) |
p03254 | s133856861 | 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 and i!=(N-1):
x-=a[i]
ans+=1
elif x-a[i]<0:
break
elif x-a[i]==0 and i==(N-1):
ans+=1
elif x-a[i]>0 and i==(N-1):
ans+=0
print(ans) |
p03254 | s250643362 | 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 == 0 or ans < N:
print(ans)
else:
print(ans-1) |
p03254 | s339376295 | 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:
print(min(N - 1, bisect_right(S, x))) |
p03254 | s915919216 | Accepted | n, x = map(int, input().strip().split())
as_ = map(int, input().strip().split())
as_ = sorted(as_)
cnt = 0
for a in as_:
if x >= a:
x -= a
cnt += 1
else:
x = 0
break
if x > 0 and cnt > 0:
cnt -= 1
print(cnt)
|
p03254 | s429925313 | Accepted | N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
SUM = 0
f = 0
for i in range(N):
SUM += A[i]
if SUM > x:
print(i)
f = 1
break
if f == 0:
if SUM == x:
print(N)
else:
print(N-1) |
p03254 | s851927721 | Accepted | # A - Candy Distribution Again
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
tmp = 0
ans = 0
for a in A:
tmp += a
if tmp<=x:
ans += 1
else:
break
if ans==N and tmp!=x:
ans -= 1
print(ans) |
p03254 | s786930356 | Accepted | N,x=map(int,input().split())
c=0
for a in sorted(map(int,input().split())):
x-=a
if x<0:
break
c+=1
else:
if x !=0:
c-=1
print(c)
|
p03254 | s214230830 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
y = x
a = sorted(a)
ans = 0
for i in a:
if y >= i:
ans += 1
y -= i
else:
break
if x > sum(a):
ans -= 1
print(ans) |
p03254 | s332220962 | Accepted | n,x = map(int,input().split())
a_inputs = sorted([int(i) for i in input().split()])
ans=0
if sum(a_inputs)<x:
ans=n-1
else:
while a_inputs:
a = a_inputs.pop(0)
if a<=x:
x-=a
ans+=1
else:
break
print(ans) |
p03254 | s693762351 | Accepted | n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
acsum = [0]
for i in range(n):
acsum.append(acsum[i] + a[i])
if acsum[-1] < x:
print(n - 1)
else:
for i in range(n + 1):
if acsum[i] == x:
print(i)
break
if acsum[i] > x:
print(i - 1)
break |
p03254 | s041233736 | Accepted | n,x = map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
ans= 0
for i in range(n-1):
if x>=a[i]:
ans+=1
x-=a[i]
else:
break
if x==a[n-1]:
ans+=1
print(ans) |
p03254 | s238703277 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
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 | s900269144 | Accepted | from itertools import accumulate
from bisect import bisect
N,x,*A=map(int, open(0).read().split())
B=list(accumulate(sorted(A)))
i=bisect(B, x)
if i==N and sum(A)!=x:
i=N-1
print(i) |
p03254 | s902321436 | Accepted | n,x = map(int,input().split())
a = sorted(map(int,input().split()))
c=0
for i in a:
if x<i:
break
x-=i
c+=1
else:
if x!=0:
c-=1
print(c) |
p03254 | s597131195 | Accepted | #!/usr/bin python3
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
def main():
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ret = 0
cnt = 0
if sum(A)<X:
print(N-1)
elif sum(A)==X:
print(N)
else:
for i in range(N):
X-=A[i]
if X<0:
break
print(i)
if __name__ == '__main__':
main() |
p03254 | s622393802 | Accepted | # coding: utf-8
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if sum(a) == x:
print(N)
else:
c = 0
for i in a:
if i > x:
break
x -= i
c += 1
if c == N:
print(c - 1)
else:
print(c) |
p03254 | s471603562 | Accepted | n, x=map(int, input().split())
c=list(map(int, input().split()))
c.sort()
ans=0
for i in range(n-1):
if c[i]<=x:
x-=c[i]
ans+=1
else:
break
if c[n-1]==x:
ans+=1
print(ans) |
p03254 | s193005317 | Accepted | N,x=[int(i) for i in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt=0
for k in a:
x -= k
if x < 0:
break
cnt +=1
if x >0:
cnt -=1
print(cnt)
|
p03254 | s780539428 | Accepted | N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(N-1):
if a[i] > x:
break
else:
x -= a[i]
ans += 1
if x == a[-1]:
ans += 1
print(ans) |
p03254 | s871235441 | Accepted | from sys import stdin
n, x = map(int, stdin.readline().rstrip().split())
a = list(map(int, stdin.readline().rstrip().split()))
ans = 0
a.sort()
for i, ai in enumerate(a):
if x < ai:
break
if i == n - 1:
if x > ai:
break
x -= ai
ans += 1
print(ans) |
p03254 | s574442056 | Accepted | n,x = map(int,input().split())
kids = list(map(int,input().split()))
kids.sort()
i=0
while i<n and x>=kids[i]:
x-=kids[i]
i+=1
if x!=0 and i==n:
i-=1
if i<0:
i=0
print(i) |
p03254 | s113481293 | Accepted | n , x = map(int , input().strip().split())
a = list(map(int , input().strip().split()))
a.sort()
if sum(a) < x:
count = -1
else:
count = 0
for i in a:
if x - i < 0:
break
x -= i
count += 1
print(count) |
p03254 | s668162754 | Accepted | N,X,*A=map(int,open(0).read().split())
c=0
for a in sorted(A):
X-=a
if X<0:
break
c+=1
print(c-(X>0)) |
p03254 | s519880601 | Accepted | N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
if X > sum(A):
print(N-1)
else:
for i in range(len(A)):
if X >= A[i]:
X -= A[i]
ans += 1
else:
break
print(ans)
|
p03254 | s904272484 | Accepted | # agc027_a.py
n,x = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) == x:
print(n)
exit()
a.sort()
cnt = 0
for i in a:
if x>=i:
cnt += 1
x -= i
if cnt == n:
cnt-=1
print(cnt)
|
p03254 | s287318254 | Accepted | n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
cnt=0
for i in range(n):
if x>0:
x-=a[i]
cnt+=1
if x>0:
cnt-=1
if x<0:
cnt-=1
print(cnt)
|
p03254 | s604450106 | Accepted | N, x = map(int, input().split())
*A, = map(int, input().split())
A.sort()
sun = 0
cnt = 0
for a in A:
if sun + a > x:
break
sun += a
cnt += 1
else:
if sun < x:
cnt = max(0, cnt-1)
print(cnt)
|
p03254 | s260434854 | Accepted | n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
ans = 0
for i in range(len(a)):
if not i == len(a)-1:
if x > a[i]:
ans += 1
x = x-a[i]
elif x == a[i]:
ans += 1
break
else: #x < a[i]
break
else:
if x == a[i]:
ans += 1
else:
pass
print (ans)
|
p03254 | s720363183 | Accepted | N, x = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
if x == sum(A):
print(N)
else:
A.sort()
ans = 0
for a in A[:-1]:
if x >= a:
ans += 1
x -= a
else:
break
print(ans)
|
p03254 | s178633888 | Accepted | import sys
N, x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = 0
a.sort()
if a[0]>x:
print(0)
sys.exit()
for i in range(N):
x -= a[i]
if x < 0:
print(ans)
sys.exit()
ans += 1
if x > 0:
print(ans-1)
else:
print(ans) |
p03254 | s247670703 | Accepted | N, x = map(int, input().split())
a = sorted(map(int, input().split()))
if sum(a) > x:
while sum(a) > x:
del a[-1]
print(len(a))
else:
print(N) if sum(a) == x else print(N-1) |
p03254 | s974697112 | Accepted | N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
count = 0
total = 0
for i in range(N):
total += a[i]
if total <=x:
count += 1
else:
break
if total < x:
count = N-1
print(count) |
p03254 | s524744336 | 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)
# 子供が喜ぶお菓子の合計sum(A)が配れるお菓子の数xより大きいか否かで場合分け
# sum(A) < x のとき子供全員にお菓子は配れるが、余りが発生するので一人は喜ばない |
p03254 | s747230101 | Accepted | a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
ans=0
h=0
for i in range(a):
if sum(c[0:i+1])>b:
ans=i
h=1
break
elif sum(c)==b:
ans=a
h=1
break
if h==0:
ans=a-1
print(ans) |
p03254 | s567881110 | Accepted | n,x = map(int,input().split())
a = list(map(int,input().split()))
#n,x = 3,30
#a = [20,30,10]
suma = sum(a)
ans = 0
if suma == x:
ans = n
elif x > suma:
ans = n -1
else:
a = sorted(a)
nokori = x
for i in a:
nokori -= i
if nokori == 0:
ans += 1
break
elif nokori < 0:
break
else:
ans += 1
print(ans) |
p03254 | s174208994 | 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 | s479076414 | Accepted | n, x = map(int, input().split())
*a, = map(int, input().split())
a.sort()
ans = 0
for i in a[:-1]:
if x >= i:
x -= i
ans += 1
ans += a[-1] == x
print(ans) |
p03254 | s559326883 | Accepted | n,x = map(int,input().split())
a = [int(i) for i in input().split()]
if sum(a)<x:
ans = n-1
elif min(a)>x:
ans = 0
else:
a_new = sorted(a)
i = 0
while i < n:
if x >= a_new[i]:
x -= a_new[i]
else:
break
i += 1
ans = i
print(ans) |
p03254 | s721967009 | Accepted | n,x=map(int,input().split())
a=list(map(int,input().split()))
b=0
a.sort()
for i in range(0,n):
x-=a[i]
b+=1
if x<=0:
break
if x==0:
print(b)
else:
print(b-1) |
p03254 | s028512462 | Accepted | N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
# print(N, x)
# print(A)
count = 0
for i in range(N):
if x >= A[i]:
count += 1
x -= A[i]
else:
break
if count == N and x != 0:
count -= 1
print(count) |
p03254 | s830699958 | Accepted | N, x = map(int, input().split())
arr = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
if x >= arr[i]:
x -= arr[i]
ans += 1
else:
break
if ans == N and x != 0:
ans -= 1
print(ans) |
p03254 | s796507347 | Accepted | N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in range(len(a)):
tmp = a[i]
if x >= tmp and i != len(a) - 1:
count += 1
x -= tmp
else:
if tmp == x:
count += 1
break
print(count) |
p03254 | s220068501 | Accepted | N,x=map(int,input().split())
A=sorted(list(map(int,input().split())))
cnt=0
for i in range(N-1):
if x-A[i]>=0:
cnt+=1
x-=A[i]
else:
break
if x-A[N-1]==0:
cnt+=1
print(cnt) |
p03254 | s677499924 | 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 | s398837283 | Accepted | n, candy = list(map(int, input().split()))
nums = list(map(int, input().split()))
nums.sort()
ans = 0
for i in range(n):
if candy >= nums[i]:
candy -= nums[i]
ans += 1
else:
break
# 配りきってまだ余っている場合
if candy > 0 and ans == n:
ans -= 1
print(ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.