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 N, M, m[101], c[101], d[10001], ans;
void input(void)
{
int i, sum=0;
scanf("%d %d",&N,&M);
for(i=1 ; i<=N ; i++)
scanf("%d",&m[i]);
for(i=1 ; i<=N ; i++)
{
scanf("%d",&c[i]);
sum+=c[i];
}
for(i=1 ; i<=sum ; i++)
d[i]=-1;
}
void process(void)
{
int i, j, limit=0;
for(i=1 ; i<=N ; i++)
{
limit+=c[i];
for(j=limit ; j>=c[i] ; j--)
{
if(d[j]<d[j-c[i]]+m[i] && d[j-c[i]]>=0)
d[j]=d[j-c[i]]+m[i];
}
}
for(i=0 ; i<=limit ; i++)
if(d[i]>=M)
{
ans=i;
break;
}
}
void output(void)
{
printf("%d",ans);
}
int main(void)
{
input();
process();
output();
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... |