This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
n,m=map(int,input().split())
a=list(map(int,input().split())) #메모리
c=list(map(int,input().split())) #가격
dp=[-999]*10001
dp[0]=0
for i in range(n):
for j in range(10001):
if(c[i]+j>10000 or dp[j]<0):continue
dp[c[i]+j]=max(dp[c[i]+j],dp[j]+a[i])
for i in range(10001):
if(dp[i]>=m):print(i);break
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |