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>
int memo[101];
int cost[101];
int d[10001];
int main()
{
int n,m,i,j,s=0;
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++)
scanf("%d",&memo[i]);
for(i=1;i<=n;i++)
scanf("%d",&cost[i]);
d[cost[1]]=memo[1];
s=cost[1];
d[0]=1;
for(i=2;i<=n;i++){
for(j=s;j>=1;j--){
if(d[j] && d[j+cost[i]]<d[j]+memo[i]) d[j+cost[i]]=d[j]+memo[i];
}
if(d[cost[i]]<memo[i]) d[cost[i]]=memo[i];
s+=cost[i];
if(s>10000) s=10000;
}
for(i=1;i<=10000;i++){
if(d[i]>=m) break;
}
printf("%d",i);
}
# | 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... |