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 <algorithm>
using namespace std;
struct Data{
int m,c;
}a[110];
int D[10101],s;
int main(){
int i,j,n,m;
scanf("%d%d",&n,&m);
for(i=1;i<=n;++i)scanf("%d",&a[i].m);
for(i=1;i<=n;++i){
scanf("%d",&a[i].c);
s+=a[i].c;
}
D[0]=1;
for(i=1;i<=n;++i){
for(j=s;j>=a[i].c;--j){
if(D[j-a[i].c])D[j]=max(D[j],D[j-a[i].c]+a[i].m);
}
}
for(i=1;i<=s;++i)if(D[i]>m)break;
printf("%d",i);
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... |