This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<stdlib.h>
int dp[102][10002];
int main()
{
int i, j, n, need, m[102][4];
scanf("%d %d",&n,&need);
for(i=1 ; i<=n ; i++) scanf("%d",&m[i][1]);
for(i=1 ; i<=n ; i++) scanf("%d",&m[i][2]);
for(i=1 ; i<=n ; i++)
{
for(j=1 ; j<=10000 ; j++) dp[i][j]=dp[i-1][j];
for(j=1 ; j<=10000 ; j++)
{
if(j-m[i][2]>=0)
{
if(dp[i][j]<dp[i-1][j-m[i][2]]+m[i][1]) dp[i][j]=dp[i-1][j-m[i][2]]+m[i][1];
}
}
}
for(j=1 ; j<=10000 ; j++)
{
for(i=1 ; i<=n ; i++)
{
if(dp[i][j]>=need)
{
printf("%d",j);
exit(1);
}
}
}
return 0;
}
# | 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... |