# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18753 | joonas | 앱 (KOI13_app) | C++98 | 0 ms | 0 KiB |
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 <memory.h>
#define max(a,b) a>b?a:b
int main(){
int i, j, N, M, m[101], c[101], *dp, SZ = 1;
scanf("%d%d",&N, &M);
for(i=0; i < N; ++i) scanf("%d",&m[i]);
for(i=0; i < N; ++i) scanf("%d",&c[i]), SZ += c[i];
dp = (int*)malloc(SZ+110);
for(i=1; i <= SZ; ++i) dp[i] = -1;
for(i=0; i < N; ++i){
for(j=SZ; j >= 0; --j){
if( dp[j] >= 0 )
dp[ j+c[i] ] = max( dp[j+c[i]], dp[j]+m[i] );
}
}
for(i=0; i <= SZ; ++i)
if( dp[i] >= M ) break;
printf("%d", i);
return 0;
}