N, S = map(int, input().split())
s = list(map(int,input().split()))
s.sort()
answer = 0
cnt = 0
for i in range(N-1, -1, -1):
answer += s[i]
cnt += 1
if answer >= S:
break
if answer < S:
print(0)
else:
print(cnt)
s = list(map(int,input().split()))
s.sort()
answer = 0
cnt = 0
for i in range(N-1, -1, -1):
answer += s[i]
cnt += 1
if answer >= S:
break
if answer < S:
print(0)
else:
print(cnt)
이렇게 풀면 메모리 ? 뭐 때문에 틀렸다고 뜨는건가요 ?
투포인터 문제던데..
댓글 0